**注:**setInterval() 方法会不停地调用函数,直到 clearInterval() 被调用或窗口被关闭。
getCode(){
var timeWare = window.setInterval(() => {
this.multiple = true;
this.counter1 -- ;
this.Text1 = this.counter1 + 's后重新提交';
if (this.counter1 === 0){
this.Text1 = '提交评审';
this.counter1 = 5;
this.multiple = true;
clearTimeout(timeWare);
}
},1000);
},
![在这里插入图片描述](https://img-blog.csdnimg.cn/9d635d9815fc458392a3d55200f45a0a.png)
注: 我这里是将封装的方法放到按钮中去进行调用,仅供参考;