vue處理路由重復的問題


最近項目開發過程中遇到了重復點擊路由會出現NavigationDuplicated: Avoided redundant navigation to current location: "/login"這個問題,重復觸發了路由導航。

這是由於vue-router版本更新之后出現的問題,在router目錄下的index的文件中添加如下代碼可以解決該問題。

1 import Router from "vue-router"
2 Vue.use(Router)
3 const originalPush = Router.prototype.push
4    Router.prototype.push = function push(location) {
5    return originalPush.call(this, location).catch(err => err)
6 }

 


免責聲明!

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



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