天天看点

封装一个常用的60秒获取验证码的功能函数

function countdown(that, isdisabled, sendText) {

    that.isdisabled = true;

    var num = 60;

    var timer = setInterval(() => {

        num--;

        that[sendText] = num + "秒后重新获取";

        if (num <= 0) {

            that.isdisabled = false;

            that[sendText] = "获取验证码";

            clearInterval(timer);

        }