SMSの確認コードを取得する - カウントダウン

VUEカウントダウン

<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);
      },
   }
公開された27元の記事 ウォン称賛21 ビュー4605

おすすめ

転載: blog.csdn.net/weixin_43997143/article/details/103298487