vue-router.esm.js?fe87:2062 Uncaught (in promise) Error: Avoided redundant navigation to current loc

vue报错
vue-router.esm.js?fe87:2062 Uncaught (in promise) Error: Avoided redundant navigation to current location: “/userPage”.
at createRouterError (vue-router.esm.js?fe87:2062)
at createNavigationDuplicatedError (vue-router.esm.js?fe87:2035)
at HashHistory.confirmTransition (vue-router.esm.js?fe87:2195)
at HashHistory.transitionTo (vue-router.esm.js?fe87:2125)
at HashHistory.push (vue-router.esm.js?fe87:2595)
at eval (vue-router.esm.js?fe87:2913)
at new Promise ()
at VueRouter.push (vue-router.esm.js?fe87:2912)
at VueComponent.created (indexPage.vue?8cc2:96)
at invokeWithErrorHandling (vue.esm.js?efeb:1863)
vue-router.esm.js?fe87:2062 Uncaught (in promise) Error: Avoided redundant navigation to current loc_第1张图片

参考博客https://www.cnblogs.com/xinheng/p/13019818.html

可以在router的配置文件中(router -> index.js)加上下面这句话,注意位置:

// 解决ElementUI导航栏中的vue-router在3.0版本以上重复点菜单报错问题
const originalPush = VueRouter.prototype.push
VueRouter.prototype.push = function push(location) {
  return originalPush.call(this, location).catch(err => err)
}

原文链接:https://blog.csdn.net/xiecheng1995/article/details/106497172/

你可能感兴趣的:(vue)