小程序实现获取短信验证码倒计时

 data: {
    timer: ‘‘,
    countDownNum: ‘获取验证码‘
  },


  clickDown: function () {
    var that = this;

    let countDownNum = ‘60‘; // 倒计时60秒
    that.setData({
      timer: setInterval(() => {
        countDownNum--;
        that.setData({
          countDownNum: countDownNum + ‘s后重新获取‘
        })
        if (countDownNum <= 0) {
          clearInterval(that.data.timer); // 移除定时器
          that.setData({
            countDownNum: ‘获取验证码‘
          })
        }
      }, 1000)
    })
  }

小程序实现获取短信验证码倒计时

上一篇:六级学习笔记(1)


下一篇:手动布设陷阱链接