vue短信验证倒计时效果

话不多说直接上代码:

<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>



猜你喜欢

转载自blog.csdn.net/A_Brave/article/details/114663227