首页 > 编程语言 >小程序验证码倒计时

小程序验证码倒计时

时间:2022-11-08 09:35:51浏览次数:35  
标签:function countdown show 程序 验证码 倒计时 settime var setData

var countdown = 60;
var settime = function (that) {
  if (countdown == 0) {
    that.setData({
      is_show: true
    })
    countdown = 60;
    return;
  } else {
    that.setData({
      is_show: false,
      last_time: countdown
    })
    countdown--;
  }
  setTimeout(function () {
    settime(that)
  }, 1000)
}
Page({
  /**
   * 页面的初始数据
   */
  data: {
    last_time: '',
    is_show: true
  },
  clickVerify: function () {
    var that = this;
    // 将获取验证码按钮隐藏60s,60s后再次显示
    that.setData({
      is_show: (!that.data.is_show) //false
    })
    settime(that);
  }
})

标签:function,countdown,show,程序,验证码,倒计时,settime,var,setData
From: https://www.cnblogs.com/Sultan-ST/p/16868581.html

相关文章