likes
comments
collection
share

Uncaught (in promise) Error: Redirected when going from "/Home" to "/Home/Handle

作者站长头像
站长
· 阅读数 16

Uncaught (in promise) Error: Redirected when going from "/Home" to "/Home/Handle

路由守卫经行拦截时,next()跳转页面报错,但是不影响路由跳转。 原因:vue-router路由版本更新后,router.push方法返回的是Promise对象,then不能正常执行 解决方式: (1)重写$router.push()方法 在router的index.js中添加以下代码,注意要在new VueRouter之前写 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) } (2)将vue-router版本回退到3.0.7,删除node_modules文件重新npm install

Uncaught (in promise) Error: Redirected when going from "/Home" to "/Home/Handle