Vue Avoided redundant navigation to current location Error


這個報錯的根源就是vue-router組件,錯誤內容翻譯一下是: Avoided redundant navigation to current location === 避免冗余導航到當前位置

這個問題的解決方案就是屏蔽它,就是重寫vue-router的push方法,不影響正常使用

在 Vue.use(VueRouter的時候),前面加上這一句即可

const originalPush = VueRouter.prototype.push;
VueRouter.prototype.push = function(location) {
  return originalPush.call(this, location).catch(err => err)
}

主要的作用就是把err給屏蔽了,不進行輸出了,頁面看不到這個錯誤,但是不影響使用

 


免責聲明!

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



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