vue项目路由跳转时控制台出现NavigationDuplicated错误,
message: "Navigating to current location (XXX) is not allowed"。

重写Router.prototype.push后还报NavigationDuplicated错误的解决方法

 

  

 解决办法:

1. 在src\router\index.js 中重写Router.prototype.push

1 const routerPush = Router.prototype.push
2 Router.prototype.push = function push (location) {
3   return routerPush.call(this, location).catch(err => err)
4 }

重写Router.prototype.push后还报NavigationDuplicated错误的解决方法

 

 

2.如果还有报错,检查是否有用大括号 {} 方式引入单个对象或单个组件

如下图:

重写Router.prototype.push后还报NavigationDuplicated错误的解决方法

请修改相应的export,并去掉大括号{},如下图。

重写Router.prototype.push后还报NavigationDuplicated错误的解决方法

 

相关文章:

  • 2022-12-23
  • 2021-10-04
  • 2022-12-23
  • 2022-01-11
  • 2022-12-23
  • 2021-07-01
  • 2021-04-23
  • 2022-12-23
猜你喜欢
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-10-25
  • 2022-12-23
  • 2021-07-02
相关资源
相似解决方案