lets,n=0;functionmainLoop(){s=setTimeout(function(){doSomeThing();mainLoop();},1000);}functiondoSomeThing(){n++;console.log(n);if(n>5){stop();}}functionstop(){console.log("---stop----")clearTimeout(s);}mainLoop();上面這段代碼為什么執(zhí)行五次以后不會自動停止啊?
大佬們遇到過這個問題嗎? setTimeout 忽然stop了?
開心每一天1111
2019-06-10 09:55:18