需求:输入手机号 -> 点击获取验证码 -> 进入60s倒计时
短信验证码登录
data: { seconds: 0, // 读秒 timer: '' // 计时器 }, let that = this // 开始倒计时 that.setData({ seconds: 60, timer: setInterval(function(){ let seconds = that.data.seconds that.setData({ seconds: seconds - 1 }) if (that.data.seconds == 0) { // 读秒结束 清空计时器 clearInterval(that.data.timer) } }, 1000) }) |