vue項目路由跳轉時控制台出現NavigationDuplicated錯誤,
message: "Navigating to current location (XXX) is not allowed"。
解決辦法:
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 }
2.如果還有報錯,檢查是否有用大括號 {} 方式引入單個對象或單個組件
如下圖:
請修改相應的export,並去掉大括號{},如下圖。