清除间隔后,我很难将时间重新启动到 10 秒。当状态为成功时,它应该再次运行设置的间隔
下面是我的代码:
<code>
var countdown = 10;
var startTime = currTimer();
var myInterval = setInterval(function() {
countdown--;
if(countdown == 0){
var endTime = currTimer();
clearInterval(myInterval);
countdown = 10;
if (status == "success"){
setTimeout(function(){myInterval}, 200);
}
}
io.sockets.emit('timer', { countdown: countdown });
}, 2000);
</code>