用span双标签包{{count}}
data() {
return{
count:''
}
},
created() {
this.countDown() // 倒计时
},
methods: {
countDown() {
const TIME_COUNT = 3
if (!this.timer) {
this.count = TIME_COUNT
this.timer = setInterval(() => {
if (this.count > 1 && this.count <= TIME_COUNT) { //限制倒计时区间
this.count--
} else {
clearInterval(this.timer) //删除定时器
this.timer = null
//跳转的页面写在此处
this.$router.push('/vaccineProtectionTk')
}
}, 1000)
}
},
},
vue 实现三秒钟倒计时 跳转页面
最新推荐文章于 2023-08-15 22:00:25 发布