html 区域
<el-button :disabled="isClick" @click="doNotRepeatOperation">
{{timer}}
</el-button>
js区域
export default {
data() {
return {
timer: '获取短信验证码',
isClick: false, // 禁止点击
}
}
methods: {
doNotRepeatOperation() {
let time = 60 //倒计时的时间秒
this.isClick = true
let inter = setInterval(() => {
this.timer = '还剩余' + time-- +'秒';
if (time < 0) {
clearInterval(inter) // 清除定时器
this.isClick = false
this.timer = '获取短信验证码'
}
}, 1000)
}
},
}