vueRouter:Avoided redundant navigation to current location

1、问题描述:

最近使用ElementUI的NavMenu 导航菜单组件的时候,发现一个导航被重复点击的时候,

element-ui.common.js?b705:3354 Error: Avoided redundant navigation to current location: "/management/arrange".
    at createRouterError (vue-router.esm.js?fe79:2060)
    at createNavigationDuplicatedError (vue-router.esm.js?fe79:2033)
    at HTML5History.confirmTransition (vue-router.esm.js?fe79:2182)
    at HTML5History.transitionTo (vue-router.esm.js?fe79:2123)
    at HTML5History.push (vue-router.esm.js?fe79:2479)
    at VueRouter.push (vue-router.esm.js?fe79:2903)
    at VueComponent.routeToItem (element-ui.common.js?b705:3381)
    at VueComponent.handleItemClick (element-ui.common.js?b705:3348)
    at invokeWithErrorHandling (vue.runtime.esm.js?0261:1854)
    at VueComponent.Vue.$emit (vue.runtime.esm.js?0261:3888)

vueRouter:Avoided redundant navigation to current location_第1张图片

2、解决方案,在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)
}

 

你可能感兴趣的:(Element,UI)