页面显示
<view class="verification" v-show="codeFlag" @click='getCode' >获取验证码</view>
<view class="verification" v-show="!codeFlag">
{{second}}秒
</view>
JS
export default {
data() {
return {
codeFlag:true,
second:60,
}
},
onLoad() {
},
methods: {
getCode(){
if(!this.codeFlag) return;
this.codeFlag=false
let timeoutID=setInterval(()=>{
if(this.second===0){
clearInterval(timeoutID)
this.second=60
this.codeFlag=true
}
--this.second
},1000)
}
}
}