本文实例为大家分享了微信小程序实现获取验证码倒计时效果的具体代码,供大家参考,具体内容如下
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 }) }, })
以上就是本文的全部内容,希望对大家的学习有所帮助,也希望大家多多支持移动技术网。
如对本文有疑问, 点击进行留言回复!!
egg项目npm/cnpm出错Connect timeout
网友评论