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)
在这里插入图片描述

参考博客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/

Logo

前往低代码交流专区

更多推荐