vue实现倒计时
第一部分
{{djs}}s跳过
第二部分
JavaScript
data(){
return {
show: true,
djs: '',
timer: null,
}
},
第三部分
JavaScript
const TIME_COUNT = 60;
if (!this.timer) {
this.djs= TIME_COUNT;
this.show = false;
this.timer = setInterval(() => {
if (this.djs> 0 && this.djs<= TIME_COUNT) {
this.djs--;
} else {
this.show = true;
clearInterval(this.timer);
this.timer = null;
}
}, 1000)
}