话不多说直接上代码:
<template>
<div>{
{
text}}</div>
</template>
<script>
export default{
data(){
return{
time:60, // 时间
text:'发送验证码'
}
}
},
methods:{
let aa = setInterval(() => {
this.time -= 1;
this.text = this.time + '秒后重新发送';
if (this.time === 0) {
this.text = '发送验证码';
this.time = 60;
clearInterval(aa);
}
}, 1000);
}
</script>