vuejs封装60秒倒计时
html代码就不写了,直接上script中的代码
export default {
data() {
return {
countdown:"",
timer: null,
}
},
methods: {
getMobileCode(){
const TIME_COUNT = 60;
if (!this.timer) {
this.countdown = TIME_COUNT;
this.timer = setInterval(() => {
if (this.countdown > 1 && this.countdown <= TIME_COUNT) {
this.countdown--;
} else {
this.countdown = ''
clearInterval(this.timer);
this.timer = null;
}
}, 1000);
}
},
}
}
以上是编程学习网小编为您介绍的“vuejs封装60秒倒计时”的全面内容,想了解更多关于 vuejs 内容,请继续关注编程基础学习网。