微信小程序倒计时60S
Posted Brian
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了微信小程序倒计时60S相关的知识,希望对你有一定的参考价值。
<button class="code-b {{disabled?‘code-h‘:‘‘}}" disabled=‘{{disabled}}‘ data-id="2" bindtap="getVerificationCode">{{time}}</button>
var interval = null //倒计时函数 Page({ data: { time: ‘获取验证码‘, //倒计时 currentTime: 60 }, }) getCode: function (options) { let that = this; let currentTime = that.data.currentTime console.log(1) interval = setInterval(function () { currentTime--; that.setData({ time: `重新获取(${currentTime}s)` }) if (currentTime <= 0) { clearInterval(interval) that.setData({ time: ‘重新获取‘, currentTime: 60, disabled: false }) } }, 1000) }, getVerificationCode() { this.getCode(); let that = this that.setData({ disabled: true }) },
以上是关于微信小程序倒计时60S的主要内容,如果未能解决你的问题,请参考以下文章