天天看點

解決vue-router報NavigationDuplicated: Avoided redundant navigation to current location 的問題

最近寫項目的時候, 重複點選路由會在控制台報這樣的錯誤。

解決vue-router報NavigationDuplicated: Avoided redundant navigation to current location 的問題

它的提示是 避免到目前位置的備援導航。 簡單來說就是重複觸發了同一個路由。

這個錯誤是 vur-router更新以後新出現的錯誤。(我使用的是 vue-router 3.2.0)出現的

解決這個錯誤也非常簡單。隻需要在router /index.js 的頁面裡面 加入

這行代碼就可以了

他的位置大概在這裡

解決vue-router報NavigationDuplicated: Avoided redundant navigation to current location 的問題