欢迎光临本站
我们一直在努力

微信小程序验证码获取倒计时效果代码分享

本文主要和大家详细介绍微信小程序实现验证码获取倒计时效果,具有一定的参考价值,感兴趣的小伙伴们可以参考一下,希望能帮助到大家。

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
 })
 },

})
登录后复制

相关推荐:

以上就是微信小程序验证码获取倒计时效果代码分享的详细内容,更多请关注有卡有网。

版权声明:本文采用知识共享 署名4.0国际许可协议 [BY-NC-SA] 进行授权
文章名称:《微信小程序验证码获取倒计时效果代码分享》
文章链接:https://www.youkayouwang.com/kaquan-baike/xcx/154080.html
本站资源仅供个人学习交流,请于下载后24小时内删除,不允许用于商业用途,否则法律问题自行承担。