美文网首页
2022-08-22 定时多久做什么事情,之后就不做了

2022-08-22 定时多久做什么事情,之后就不做了

作者: 流泪手心_521 | 来源:发表于2022-08-22 17:42 被阅读0次
 data() {
    return {
      timer:null,
      count:0,
    }
  },
//方法
    setTime(){
        const TIME_COUNT = 3;
        if (!this.timer) {
            this.count = TIME_COUNT;
            this.timer = setInterval(() => {
                if (this.count > 0 && this.count <= TIME_COUNT) {
                    this.count--;
                    var flag = 0;
                    var text = document.getElementById("myDiv");
                    if (!flag&&this.count>0){
                         text.className= "warpNum";
                         flag = 1;
                    }else{
                        text.className = "warpNumDefault";
                        flag = 0;
                    }
                } else {
                    clearInterval(this.timer);
                    this.timer = null;
                }
            }, 30000)
        }
    },

this.setTime()调用

相关文章

网友评论

      本文标题:2022-08-22 定时多久做什么事情,之后就不做了

      本文链接:https://www.haomeiwen.com/subject/wuwigrtx.html