NavigationDuplicated {_name: "NavigationDuplicated", name: "NavigationDuplicated", message: "Navigating to current location ("/users") is not allowed", stack: "Error↵    at new NavigationDuplicated (webpack-int…e_modules/element-ui/lib/mixins/emitter.js:29:22)"}
message: "Navigating to current location ("/users") is not allowed"
name: "NavigationDuplicated"
_name: "NavigationDuplicated"
stack: "Error↵    at new NavigationDuplicated (webpack-internal:///./node_modules/vue-router/dist/vue-router.esm.js:1975:14)↵    at HashHistory.confirmTransition (webpack-internal:///./node_modules/vue-router/dist/vue-router.esm.js:2091:18)↵    at HashHistory.transitionTo (webpack-internal:///./node_modules/vue-router/dist/vue-router.esm.js:2035:8)↵    at HashHistory.push (webpack-internal:///./node_modules/vue-router/dist/vue-router.esm.js:2460:10)↵    at VueRouter.push (webpack-internal:///./node_modules/vue-router/dist/vue-router.esm.js:2783:18)↵    at VueComponent.routeToItem (webpack-internal:///./node_modules/element-ui/lib/menu.js:791:22)↵    at VueComponent.handleItemClick (webpack-internal:///./node_modules/element-ui/lib/menu.js:763:14)↵    at invokeWithErrorHandling (webpack-internal:///./node_modules/vue/dist/vue.runtime.esm.js:1853:26)↵    at VueComponent.Vue.$emit (webpack-internal:///./node_modules/vue/dist/vue.runtime.esm.js:3876:9)↵    at VueComponent.dispatch (webpack-internal:///./node_modules/element-ui/lib/mixins/emitter.js:29:22)"
__proto__: Error

就是报这样子的错误,原因就是你升级到vue-cli4.x的版本

原因:在路由中添加了相同的路由。
解决:
重写路由的push方法

在src/router/index.js 里面import Router from 'vue-router'下面写入下面方法即可

/**
 * 重写路由的push方法--->这个是vue-cli4.x以上的坑,不然的话,你是跳转不了的
 */
const routerPush = VueRouter.prototype.push
VueRouter.prototype.push = function push(location) {
  return routerPush.call(this, location).catch(error => error)
}

 

完美解决了,收工!!!!! 

Logo

前往低代码交流专区

更多推荐