javascript - 主键中调用vue-router的push方法跳转页面无反应?
本文介绍了javascript - 主键中调用vue-router的push方法跳转页面无反应?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
问 题
代码如下
methods: {
...mapActions(['doLogin']),
login() {
this.doLogin({ username: this.username, password: this.password }).then((loginInfo) => {
if (loginInfo.error === 200) {
console.log('登录成功');
if (this.$route.query.redirect !== undefined) {
this.$router.push(this.$route.query.redirect);
} else {
this.$router.push('/index');
}
} else {
console.log(loginInfo.msg);
}
});
},
},
登录成功有打出来,但是页面静止没有跳转,也没有报错
解决方案
搞清楚了…this.$router.push是有效的,但是我登录状态没有设置好,程序判断没有登录,又跳回来了
这篇关于javascript - 主键中调用vue-router的push方法跳转页面无反应?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文