时间:2021-07-01 10:21:17 帮助过:87人阅读
本文实例为大家分享了微信小程序实现获取验证码倒计时效果的具体代码,供大家参考,具体内容如下

wxml
<button disabled='{{disabled}}' data-id="2" bindtap="getVerificationCode">
{{time}}
</button>js
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
})
},
})上面是我整理给大家的,希望今后会对大家有帮助。
相关文章:
webpack 4.0.0-beta.0版本新特性(详细教程)
在vue2.0组件中如何实现传值、通信
在vue.js中实现分页中单击页码更换页面内容
以上就是通过微信小程序如何实现验证码获取倒计时效果的详细内容,更多请关注Gxl网其它相关文章!