redirected when going from “/login“ to “/“ via a navigation guard.

路由全局守卫报错,不解决也不影响,但是控制台一直报错,网上给出的解决方案二
1 给路由降级
vue-router降低版本到3.0.7
2 复制一段代码到路由index中

const originalPush = VueRouter.prototype.push
VueRouter.prototype.push = function push(location, onResolve, onReject) {
    
    
if (onResolve || onReject) return originalPush.call(this, location, onResolve, onReject)
return originalPush.call(this, location).catch(err => err)
}

找到一个其他办法

this.$router.replace("/")
修改后
this.$router.replace("/").catch(() =>{});
这样就可以
解释:意思是在router 包升级后 login页面在跳转的时候抛出了一个promise异常 没有接收它 所以报了这个错误

参考来源:来源

猜你喜欢

转载自blog.csdn.net/zyue_1217/article/details/131188620