(多次点击相同路由报错)Error:vue-router.esm.js?fe87:2065 Uncaught (in promise) NavigationDuplicated: Avoided redundant navigation to current location: "/system/user"
问题:
- 点击多次相同的路由报错

解决方法一:
-
全局处理,只需要加一次
-
在引入
vue-router的地方加上以下代码,统一处理错误
import Router from 'vue-router'
const originalPush = Router.prototype.push
// 重写原型上的push方法,统一处理错误信息
Router.prototype.push = function push(location) {
return originalPush.call(this, location).catch(err => err)
}
解决方法二:
- 局部处理,每次都在报错的地方加
nextGo(){
this.$router.push({
path:'/echarts'
}
).catch(err => {}) //添加catch捕捉错误
}

浙公网安备 33010602011771号