最近需要在页面里做个倒计时,发现用clearInterval()清除定时器失效,
解决办法就是挂载到window上
this.timer = window.setInterval(() => {
this.onPlayerTimeupdate();
}, 300);
window.clearInterval(this.timer);
this.timer=null;
最近需要在页面里做个倒计时,发现用clearInterval()清除定时器失效,
解决办法就是挂载到window上
this.timer = window.setInterval(() => {
this.onPlayerTimeupdate();
}, 300);
window.clearInterval(this.timer);
this.timer=null;