解决方案:在router的index.js文件夹中添加如下代码
Vue.use(VueRouter)
// 解决ElementUI导航栏中的vue-router在3.0版本以上重复跳转一个路径报错问题
let originPush = VueRouter.prototype.push
let originReplace = Vue.prototype.originReplace
VueRouter.prototype.push = function (location,res,rej) {
if (res && rej ) {
originPush.call(this,location,res,rej)![在这里插入图片描述](https://img-blog.csdnimg.cn/6269dc1bdba94ca88480f4a642496a4d.jpeg#pic_center)
} else {
originPush.call(this,location,()=>{},()=>{})
}
}
VueRouter.prototype.replace = function(location ,res,rej) {
if (res && rej) {
originReplace.call(this,location,res,rej)
} else {
originReplace.call(this,location,() => {},() => {})
}
}