項目中
報錯: 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)
}

然后重新運行項目,問題解決
