解决vuerouter报NavigationDuplicated: Avoided redundant navigation to current location 的问题
生活随笔
收集整理的這篇文章主要介紹了
解决vuerouter报NavigationDuplicated: Avoided redundant navigation to current location 的问题
小編覺得挺不錯的,現在分享給大家,幫大家做個參考.
最近寫項目的時候, 重復點擊路由會在控制臺報這樣的錯誤。
它的提示是 避免到當前位置的冗余導航。 簡單來說就是重復觸發了同一個路由。
這個錯誤是 vur-router更新以后新出現的錯誤。(我使用的是 vue-router 3.2.0)出現的
解決這個錯誤也非常簡單。只需要在router /index.js 的頁面里面 加入
const originalPush = VueRouter.prototype.push
VueRouter.prototype.push = function push(location) {
return originalPush.call(this, location).catch(err => err)
}
這行代碼就可以了
他的位置大概在這里
總結
以上是生活随笔為你收集整理的解决vuerouter报NavigationDuplicated: Avoided redundant navigation to current location 的问题的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: CTF中常见Web源码泄露总结
- 下一篇: 【Github】Git问题解决:warn