@H_404_0@倒计时功能是一个比较常见的功能,比如用户获取验证码就需要用到。这里记录一下在微信小程序里面倒计时功能的简单实现。
@H_404_0@直接看看代码吧
<div class="jb51code">
<pre class="brush:js;">
//倒计时60秒
function countDown(that,count) {
if (count == 0) {
that.setData({
timeCountDownTop: '获取验证码',counting:false
})
return;
}
that.setData({
counting:true,timeCountDownTop: count + '秒后重新获取',})
setTimeout(function(){
count--;
countDown(that,count);
},1000);
}