作为一个合格的前端,样式我就不写了
页面结构
<button @click=“codeClick” v-if=“changess”>获取验证码
<button @click=“codeClick” :disabled=“disabled” v-else>{{this.second}}后重试
js
data(){
return {
showText:true,
second:59,
disabled:false,
changess:true
}
}
再接口回调成功里面
this.changess = false;
this.disabled = true
// console.log("1")
this.showText = false
var interval = setInterval(() => {
--this.second
}, 1000)
setTimeout(() => {
clearInterval(interval)
this.showText = true
this.second = 59
this.disabled = false
this.changess = true;
}, 60000)