直接上代码,不啰嗦
vue实现登录之后几秒进入系统或者几秒之后进入某个页面
<template>
<div>
<h1>欢迎来到Vue.js项目首页</h1>
<h2>你将在<span style="color:red">{{time}}</span>秒后进入系统</h2>
</div>
</template>
<script>
export default {
name: 'HelloWorld',
data () {
return {
time:0,
}
},
methods:{
countDown(){
this.time--;
}
},
mounted(){
this.time=5;
setInterval(this.countDown,1000);
},
watch:{
'time':function(newVal,oldVal){
if(newVal==0){
this.$router.push('/resource');// 你想要跳转的页面路径
}
}
}
}
</script>
<style scoped>
</style>
1565

被折叠的 条评论
为什么被折叠?



