如何杀死一个的setTimeout()函数函数、setTimeout

由网友(羽墨凌霄)分享简介:我使用的setTimeout()函数,通过我的应用程序,但是当它的时间来收集垃圾。该方法仍然运行,并呼吁一个函数。如何从调用某个功能停止。我试着将它设置为空,但它不工作I use the setTimeout() function through my application but when its time to...

我使用的setTimeout()函数,通过我的应用程序,但是当它的时间来收集垃圾。该方法仍然运行,并呼吁一个函数。如何从调用某个功能停止。我试着将它设置为空,但它不工作

I use the setTimeout() function through my application but when its time to garbage collect. the method still runs and calls on a function. How do I stop it from calling on a certain function. I tried setting it to null but it doesnt work

推荐答案

的setTimeout 返回引用超时,而当你调用 clearTimeout 就可以使用。

setTimeout returns an reference to the timeout, which you can then use when you call clearTimeout.

var myTimeout = setTimeout(...);
clearTimeout(myTimeout);
阅读全文

相关推荐

最新文章