template
   <span v-if="codeShow" @click="getPhoneCode">获取验证码</span>
   <span v-if="!codeShow">{{count}}秒后重试</span>
script
data(){
  return {
   codeShow: true,  //判断显示隐藏
   count: '',     //显示时的文字内容
   timer: null,    
  }
 },
 getPhoneCode() {
      //点击获取验证码
      const TIME_COUNT = 60;  //倒计时60秒
      if (!this.timer) {
        this.count = TIME_COUNT;
        this.codeShow = false;
        this.timer = setInterval(() => {
          if (this.count > 0 && this.count <= TIME_COUNT) {
            this.count--;
          } else {
            this.codeShow = true;
            clearInterval(this.timer);
            this.timer = null;
          }
        }, 1000);
      }
    },

相关文章:

  • 2021-08-31
  • 2021-09-14
  • 2021-10-29
  • 2022-12-23
  • 2023-01-07
  • 2021-12-09
  • 2022-12-23
猜你喜欢
  • 2021-08-23
  • 2021-12-13
  • 2021-07-10
  • 2021-12-24
  • 2021-09-26
  • 2022-12-23
  • 2021-10-29
相关资源
相似解决方案