微信小程序“获取验证码”button倒计时

微信小程序button倒计时禁用
获取验证码→倒计时(button禁用)→重新发送

代码片段(https://developers.weixin.qq.com/s/ug9qiymt7G79)

js

const app = getApp()

Page({
  data: {
    disabled: false,
    codename: '获取验证码'
  },
  
  onLoad: function () {
    
  },
  //button
  getVerificationCode: function () {
    var that = this
    var num = 5;
    that.setData({
      codename: num + "s"
    })
    var timer = setInterval(function () {
      num--;
      if (num <= 0) {
        clearInterval(timer);
        that.setData({
          codename: '重新发送',
          disabled: false
        })
      } else {
        that.setData({
          codename: num + "s",
          disabled: true
        })
      }
    }, 1000)
  }
})

其他

SSM实现简单发送邮件

相关文章:

  • 2021-12-05
  • 2021-12-05
  • 2021-12-05
  • 2022-01-13
  • 2021-12-02
猜你喜欢
  • 2021-12-15
  • 2021-12-05
  • 2021-12-05
  • 2021-12-05
  • 2021-12-02
  • 2021-12-05
相关资源
相似解决方案