Skip to content

QingKaa/codeTimer

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 

Repository files navigation

codeTimer

全局持久化验证码倒计时

Vue中使用:

main.js中挂载

import Vue from "vue"
import codeTimer from "@/utils/codeTimer.js"

Vue.prototype.$codeTimer = new codeTimer()

页面使用:

login.vue

created(){
    let phoneCodeId = this.$codeTimer.$on("phone", (res) => {
      if (!res) return;
      this.phoneTimer.text = res.text; // 显示在按钮的文字:获取验证码、 xx's
      this.phoneTimer.lessTime = res.lessTime; // 倒计时剩余时间
    });

    this.$once("hook:beforeDestroy", () => {
      this.$codeTimer.$off("phone", phoneCodeId);
    });
},

methods:{
    getCode(){
        //...获取验证码成功
        this.$codeTimer.start("phone");
    }
}

About

a global messageTImer 全局验证码倒计时

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors