<div v-if="is_show_yzm">
<ul>
<li>验证码</li>
<li class="yzm_css">
<input type="text" placeholder="请输入" ref="yzm" />
</li>
<li
class="studentInfoEdit_get_yzm"
@click="get_yzm()"
ref="yzm_text"
>
{{ content }}
</li>
</ul>
<div class="clear"></div>
</div>
data() {
return {
content: "发送验证码", // 按钮里显示的内容
totalTime: 10, //记录具体倒计时时间
canClick: true //添加canClick
};
},
........
//验证码倒计时
yzm_count_down() {
if (!this.canClick) return; //改动的是这两行代码
this.canClick = false;
this.content = this.totalTime + "s后重新发送";
let clock = window.setInterval(() => {
this.totalTime--;
this.content = this.totalTime + "s后重新发送";
if (this.totalTime < 0) {
window.clearInterval(clock);
this.content = "重新发送验证码";
this.totalTime = 10;
this.canClick = true; //这里重新开启
}
}, 1000);
},