更新:
vue已經修改此bug。
https://github.com/vuejs/vue-router/blob/dev/CHANGELOG.md
裝一下依賴包吧。
以下爲原文:
原文參考鏈接:https://blog.csdn.net/weixin_43202608/article/details/98884620
今天寫項目遇到一個報錯:Uncaught (in promise) NavigationDuplicated {_name: "NavigationDuplicated", name: "NavigationDuplicated"}。反覆檢查後沒有發現任何問題。
查了issues以後發現已經有人提了,並且已經修復此bug了。
有些bug,你一生只會遇到一次。
解決方法一:
把node_modules文件夾刪除, 重新npm i 以後,問題迎刃而解。
解決方法二:
不想刪除node_modules可以只重新下載npm i [email protected] -S
終極方法三(不建議):
在main.js中捕獲路由報錯,寫入如下代碼:import Router from 'vue-router' const originalPush = Router.prototype.push Router.prototype.push = function push(location) { return originalPush.call(this, location).catch(err => err) }
以上。