前言
- vue:V2.5.2
- vue-router版本:V3.0.1
Error
vue-router.esm.js?fe87:2046 Uncaught (in promise) Error: Redirected when going from "/login" to "/email/list" via a navigation guard.
at createRouterError (vue-router.esm.js?fe87:2046)
at createNavigationRedirectedError (vue-router.esm.js?fe87:2005)
at eval (vue-router.esm.js?fe87:2376)
at Object._callee$ (permission.js?2b1d:6)
at tryCatch (runtime.js?1e13:62)
at Generator.invoke [as _invoke] (runtime.js?1e13:296)
at Generator.prototype.<computed> [as next] (runtime.js?1e13:114)
at step (asyncToGenerator.js?7b11:17)
at eval (asyncToGenerator.js?7b11:28)
Solution
src/router/index.js
Vue.use(VueRouter)
//获取原型对象上的push函数
const originalPush = VueRouter.prototype.push
//修改原型对象中的push方法
VueRouter.prototype.push = function push(location) {
return originalPush.call(this, location).catch((err) => err)
}
参考链接
Redirected when going from “/login“ to “/“ via a navigation guard错误