Get SMS verification code - Countdown

vue Countdown

<span v-if='codeState' @click='sendCode'>验证码</span>
<span v-else>{{auth_time}}s</span>
export default {
data(){
      return{
      codeState:true,
      auth_time:0
      }
  }
},
methods: {
      sendCode () {
            this.codeState = false;
            this.auth_time = 60;
            var auth_timetimer =  setInterval(()=>{
                this.auth_time--;
                if(this.auth_time<=0){
                    this.codeState = true;
                    clearInterval(auth_timetimer);
                }
            }, 1000);
      },
   }
Published 27 original articles · won praise 21 · views 4605

Guess you like

Origin blog.csdn.net/weixin_43997143/article/details/103298487