template模块:
data模块:
methods模块:
template部分:
这个可以动态的改变秒数,也就是每过一秒会刷新一下这个值
<view class="yzm" @click="getyzm()">{{!captchaTime?'获取验证码':captchaTime+'s'}}</view>
js部分:
代码复制:
if(this.captchaTime > 0){
uni.showToast({
title:'不能重复获取',
icon:'none'
})
return ;
}else {
this.captchaTime = 60;
let timer = setInterval(()=>{
this.captchaTime--;
// console.log(this.captchaTime)
if(this.captchaTime < 1){
clearInterval(timer);
this.captchaTime = 0
}
},1000)
}