按钮
<input type="button" value="获取验证码" @click="settime2($event)">
先验证手机号码,然后倒计时 (定义countdown:60 (60秒可替换))
settime2: function(e) {
if (this.tel == '') {
this.tan_nav = "请输入手机号码";
this.tan = true;
return;
} else if (!this.tel.match(/^1[2|3|4|5|6|7|8|9]\d{9}$/)) {
this.tan_nav = "手机号码有误";
this.tan = true;
return false;
} else if (vm.countdown == 0) {
e.target.removeAttribute("disabled");
e.target.value = "免费获取验证码";
vm.countdown = 60;
return;
} else {
e.target.setAttribute("disabled", true);
e.target.value = "重新发送(" + vm.countdown + ")";
vm.countdown--;
}
setTimeout(function() {
vm.settime2(e)
}, 1000)
},