登录中获取验证码的节流

一. 验证码框

登录中获取验证码的节流_第1张图片


     {{ text }}
    

二.点击事件

data 中声明

text: "获取验证码",
disabled: false,

methods 事件

checkbtn() {
    this.disabled = true
    let sum = 60
    this.text = sum + 's后在尝试'
    let set
    set = setInterval(() => {
        sum--
        this.text = sum + 's后在尝试'
        if (sum == 0){
            this.disabled = false
            this.text = "获取验证码"
            clearInterval(set)
        }
    }, 1000)
},

登录中获取验证码的节流_第2张图片

是不是很简单!

你可能感兴趣的:(经验记载,vue.js,javascript,前端)