[vue报错vue-router.esm.js?8c4f:2007 Uncaught (in promise) NavigationDuplicated {_name: "NavigationDuplicated", name: "NavigationDuplicated"}]

img

解决方法一:经过多次尝试发现原因可能是 在重新下载依赖包时,安装的vue-router还是之前出错的那个版本,

解决方法也很简单,在项目目录下运行 npm i vue-router@3.0 -S 即可。

解决方法二:如果你不想用方法一那就在 main.js里添加一段代码。

import Router from 'vue-router'
const routerPush = Router.prototype.push
Router.prototype.push = function push(location) {
  return routerPush.call(this, location).catch(error=> error)
}
原文地址:https://www.cnblogs.com/rxfn/p/13086060.html