vue 倒计时结束跳转页面实现代码
更新时间:2023年10月12日 10:37:32 作者:爱喝冰可乐
在商场大家经常看到停车收费倒计时支付页面,今天小编通过本文给大家分享vue 倒计时结束跳转页面功能,感兴趣的朋友一起看看吧
vue 倒计时结束跳转页面

data () {
return {
timers: null,
countDown: null
}
}count () {
const count = 15
this.countDown = count
this.timers = setInterval(() => {
if (this.countDown > 0) {
this.countDown--
} else {
clearInterval(this.timers)
this.$router.push('/login')
}
}, 1000)
}激活条件:this.count()
vue中倒计时3秒后跳转页面
<template>
<div id="home">
<div>{{ count }}s后将自动跳转到登录页!</div>
</div>
</template>
<script>
export default {
data(){
return {
count:"",//倒计时
}
}
},
created(){
??????this.threeGo()
},
methods: {
//3秒后进入跳转页面
threeGo(){
const TIME_COUNT = 3;
if(!this.timer){
this.count = TIME_COUNT;
this.show = false;
this.timer = setInterval(()=>{
if(this.count > 0 && this.count <= TIME_COUNT){
this.count--;
}else{
this.show = true;
clearInterval(this.timer);
this.timer = null;
//跳转的页面写在此处
this.$router.push({
path: ''
});
}
},1000)
}
},
}
</script>到此这篇关于vue 倒计时结束跳转页面的文章就介绍到这了,更多相关vue 倒计时跳转页面内容请搜索脚本之家以前的文章或继续浏览下面的相关文章希望大家以后多多支持脚本之家!
相关文章
Vue3-新特性defineOptions和defineModel示例详解
在Vue3.3中新引入了defineOptions宏主要是用来定义Option API的选项,可以用defineOptions定义任意的选项,props、emits、expose、slots除外,本文给大家介绍Vue3-新特性defineOptions和defineModel,感兴趣的朋友一起看看吧2023-11-11
详解从零搭建 vue2 vue-router2 webpack3 工程
本篇文章主要介绍了详解从零搭建 vue2 vue-router2 webpack3 工程,小编觉得挺不错的,现在分享给大家,也给大家做个参考。一起跟随小编过来看看吧2017-11-11
vue3配置permission.js和router、pinia实现路由拦截的简单步骤
这篇文章主要介绍了如何在场景网站中实现对未登录用户访问的拦截,通过配置Pinia,创建一个user.js文件来存储用户数据,并在main.js中进行配置,同时通过在router目录下创建permission.js文件,可以实现对未登录用户的拦截,需要的朋友可以参考下2024-11-11


最新评论