当前位置:网站首页>Seconds understand the delay and timing function of wechat applet

Seconds understand the delay and timing function of wechat applet

2022-07-07 02:03:00 Full stack o-jay

The time delay function , Print once in two seconds “hello”.

 setTimeout(()=>
      {
    
         console.log("hello");
      }, 2*1000);

Timing function , Print every two seconds “hello”.

 setInterval(()=>
      {
    
         console.log("hello");
      }, 2*1000);

If you want to Cancel timing function , be

 var k = setInterval(()=>
      {
    
         console.log("hello");
      }, 2*1000);
clearInterval(k);  

The above function can cancel the timer ,k It's a timer id.

原网站

版权声明
本文为[Full stack o-jay]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/02/202202130908398331.html