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