这篇文章主要介绍小程序怎样实现点击倒计时,文中介绍的非常详细,具有一定的参考价值,感兴趣的小伙伴们一定要看完!
小程序实现点击倒计时的代码
var interval = null //倒计时函数
Page({
data: {
date:'请选择日期',
fun_id:2,
time: '获取验证码', //倒计时
currentTime:61
},
getCode: function (options){
var that = this;
var currentTime = that.data.currentTime
interval = setInterval(function () {
currentTime--;
that.setData({
time: currentTime+'秒'
})
if (currentTime <= 0) {
clearInterval(interval)
that.setData({
time: '重新发送',
currentTime:61,
disabled: false
})
}
}, 100)
},
getVerificationCode(){
this.getCode();
var that = this
that.setData({
disabled:true
})
},
})
<button disabled='{{disabled}}' data-id="2" bindtap="getVerificationCode">
{{time}}
</button>
以上是“小程序怎样实现点击倒计时”这篇文章的所有内容,感谢各位的阅读!希望分享的内容对大家有帮助,更多相关知识,欢迎关注天达云行业资讯频道!