【Vue】解決vue-router報 NavigationDuplicated: Avoided redundant navigation to current location


image
它的提示是 避免到當前位置的冗余導航。就是重復觸發了同一個路由。
報錯顯示路由重復,對功能沒有影響。

解決方法

router 文件下添加下面代碼即可

// 解決ElementUI導航欄中的vue-router在3.0版本以上重復點菜單報錯問題
const originalPush = Router.prototype.push
Router.prototype.push = function push(location) {
   return originalPush.call(this, location).catch(err => err)
}

image


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM