js 倒计时写法

倒计时6s后关闭

var times = 6;
var timer = null; countdown() {
this.timer = setInterval(() => { this.times--; if (this.times === 0) { clearInterval(this.timer); // do something } }, 1000) };

如下:

 

 

 

posted @ 2021-12-09 14:39  君君仔的随笔  阅读(73)  评论(0)    收藏  举报