unaipp 发送验证码倒计时
view代码
<view class="margin-top" @tap="getCheckNum()"> <view class="bg-purple">{{!codeTime?'获取验证码':codeTime+'s' + '后重试'}}</view> </view>
css代码
.bg-purple { text-align: center; line-height: 45px; border-radius: 50px; }
js代码
export default { data() { return { codeTime: 0, } }, methods: { getCheckNum() { if (this.codeTime > 0) { uni.showToast({ title: '不能重复获取', icon: "none" }); return; } else { this.codeTime = 60 let timer = setInterval(() => { this.codeTime--; if (this.codeTime < 1) { clearInterval(timer); this.codeTime = 0 } }, 1000) } } }, }
本文来自博客园,作者:奔跑的前端猿,转载请注明原文链接:https://www.cnblogs.com/sxdpanda/p/13246290.html
如需了解更多文章,请移步:https://www.yuque.com/sxd_panda