错误:vue-router.esm.js?8c4f:2008 Uncaught (in promise) NavigationDuplicated: Avoided redundant navigation to current location: “/”.
避免到当前位置的冗余导航:“/”,报错信息提示当前已经是/的页面,无需跳转
解决方案
引入vue-router名字
import VueRouter from 'vue-router'
//获取原型对象上的push函数
const originalPush = VueRouter.prototype.push
//修改原型对象中的push方法
VueRouter.prototype.push = function push(location) {
return originalPush.call(this, location).catch(err => err)
}