微信小程序 —— 验证码获取倒计时效果
发布日期:2021-05-07 20:11:07 浏览次数:20 分类:精选文章

本文共 688 字,大约阅读时间需要 2 分钟。

è¿éåå¾çæè¿°

è¿éåå¾çæè¿°

这里写图片描述

wxml

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

})

————————————————
原文链接:https://blog.csdn.net/Wu_shuxuan/article/details/78539075

 

上一篇:phpStudy for Linux (lnmp+lamp一键安装包)
下一篇:html5语义化标签(非常好)原文链接:http://www.daqianduan.com/6549.html

发表评论

最新留言

很好
[***.229.124.182]2025年03月31日 05时39分01秒