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.bmabk.com/index.php/post/158685.html