Vue中报错Uncaught (in promise)解决方案


  • 今天在写vue项目配置好路由点击菜单时,突然在控制台报错。

  • 错误信息如下:

  • Uncaught (in promise) NavigationDuplicated {_name: "NavigationDuplicated", name: "NavigationDuplicated"};

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

    • 解决方法也很简单,在项目目录下运行 npm i [email protected] -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)
}


你可能感兴趣的:(Vue全家桶)