data: {
timer: \'\',
countDownNum: \'获取验证码\'
},
clickDown: function () {
var that = this;
let countDownNum = \'60\'; // 倒计时60秒
that.setData({
timer: setInterval(() => {
countDownNum--;
that.setData({
countDownNum: countDownNum + \'s后重新获取\'
})
if (countDownNum <= 0) {
clearInterval(that.data.timer); // 移除定时器
that.setData({
countDownNum: \'获取验证码\'
})
}
}, 1000)
})
}
请发表评论