//我之前是写安卓的,对js也不熟悉,仅供参考,这个是用于注册的时候倒计时获取短信验证码的,不知道你要的是不是这个。
data: {
timeCount: ‘60’,
timeCountFinal: ‘60’
},
//倒计时
countDown: function () {
var that = this;
var currentTime = that.data.timeCountFinal;
var interval = setInterval(function () {
currentTime–;
that.setData({
timeCount: currentTime
})
if (currentTime <= 0) {
clearInterval(interval)
currentTime = -1
that.setData({
timeCount: that.data.timeCountFinal
})
}
}, 1000)
},