例如,我在几个地方使用以下行清除状态。我有一些闲逛时间超过10秒钟或更长时间,并且如果用户单击四周,操作可能会在不正确的时间间隔发生。
window.setTimeout(function() { removeStatusIndicator(); }, statusTimeout);
是否可以使用一些jQuery或JavaScript代码取消或取消此操作,所以我没有这个过程了吗?
例如,我在几个地方使用以下行清除状态。我有一些闲逛时间超过10秒钟或更长时间,并且如果用户单击四周,操作可能会在不正确的时间间隔发生。
window.setTimeout(function() { removeStatusIndicator(); }, statusTimeout);
是否可以使用一些jQuery或JavaScript代码取消或取消此操作,所以我没有这个过程了吗?
Answers:
var timer1 = setTimeout(function() { removeStatusIndicator(); }, statusTimeout);
clearTimeout(timer1)
window.clearTimeout(timer1)
无法在Node.js中使用。只需使用clearTimeout(timer1)
或global.clearTimeout(timer1)
setTimeout(removeStatusIndicator, ...)
,即removeStatusIndicator
未调用该函数。
setTimeout( func(), 0 )
而不是setTimeout( func, 0 )