vue里面实现短信验证倒计时

 template:

 获取验证码
 {{countdown }}s后可重试

 script:

data(){
    return{
        countdown:60,
        timer:'',
        isShowGetCode:true
    }
},
methods:{
    getIdentifyCode(){
        this.countDown()
        this.isShowGetCode = false
    },
    countDown(){
      const self = this
      this.timer =  setInterval(() =>{
         self.countdown--
         if(self.countdown === 0){
           clearInterval(self.timer)
           self.countdown = 60
           self.isShowGetCode = true
         }
       },1000)
    },
}

vue里面实现短信验证倒计时_第1张图片

 

你可能感兴趣的:(vue)