專案中
報錯: NavigationDuplicated: Avoided redundant navigation to current location:
(NavigationDuplicated: 避免了對當前位置的冗余導航)
解決方法:
這個報錯的關鍵是this.$router.push(...).catch(err => err)要有后面的catch,因為跳轉方法回傳了一個promise物件,要有處理拒絕的方法,
首先檢查,路由跳轉的時候是不是呼叫的push方法,還是用的replace?
打開 router 檔案夾下的 index.js(路由檔案)檔案中添加如下代碼:
// pust方法
const routerRePush = VueRouter.prototype.push VueRouter.prototype.push = function (location) { return routerRePush.call(this, location).catch(error => error) } 
// replace 方法 const routerReplace = VueRouter.prototype.replace VueRouter.prototype.replace = function (location) { return routerReplace.call(this, location).catch(error => error) }

然后重新運行專案,問題解決
轉載請註明出處,本文鏈接:https://www.uj5u.com/qianduan/308389.html
標籤:HTML5
上一篇:form表單的默認行為
