export default {
name: 'Welcome',
data() {
return {
count: 3,
};
},
methods: {
goToLogin() {
if (!this.timer) {
let that = this;
this.timer = setInterval(() => {
that.count--;
if (that.count === 0) {
// 判断浏览器用户信息的缓存是否存在
if (localStorage.getItem("loginUser") !== null) {
// 存在,完成倒计时跳转home主页面
that.$router.push({path: 'home'});
} else {
// 不存在,完后倒计时跳转登录页面
that.$router.push({path: 'login'});
}
// 清除倒计时
clearInterval(that.timer);
}
}, 1000)
}
}
},
created() {
this.goToLogin();
},
mounted() {
}
};