在a.js文件中 我有一个名为的函数:
Move(coordinates,callback) {
//Move the cursor from point A to point B based on the coordinates as parameter
});
在b.js文件中 我调用这个函数是因为我想看到光标每 30 秒缓慢移动一次。 这是调用:
for(i=0;i<6;i++)
{
setTimeout(Move(inputcordinates,events = {
//someevents
}),30000);
}
问题是当页面加载时,函数正在执行并且光标已经移动了6次到该位置, 延迟没有发生在我眼前,但功能肯定会执行。
上面显示的代码可能存在什么问题? 我把代码增加到120000左右还是没有效果。
最佳答案
这是因为你直接调用了你的函数。你必须这样写:
setTimeout(function() {
Move(inputcordinates,events = {
//someevents
});
}, 30000)
关于javascript - SetTimeout 功能未发生,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33756264/