效果
![在这里插入图片描述](https://i-blog.csdnimg.cn/blog_migrate/cc29a7896c2261954673a040c08fa0b4.png)
<el-form-item prop="verificationCode">
<el-input type="text" v-model="ruleForm.verificationCode" autocomplete="off" placeholder="验证码" class="verificationCode"></el-input>
<span class="getCode" @click="getCode()" v-show="show">获取验证码</span>
<span v-show="!show" class="getCode">重新发送({{count}}s)</span>
</el-form-item>
data () {
return{
show: true,
count: 60,
timer: null,
}
}
_this.timer = setInterval(() => {
if (_this.count > 0) {
_this.show = false;
_this.count--;
console.log( _this.count)
} else {
_this.show = true;
clearInterval(_this.timer);
_this.timer = null;
_this.count = 60;
}
}, 1000)