vue项目中,点击左侧菜单栏中的项,重复点击时会报错,解决这个问题,首先找到项目中管理路由的文件,一般是router/index.js,有的直接就是router.js。解决代码:
import Router from 'vue-router';
Vue.use(Router);
// 解决ElementUI导航栏中的vue-router在3.0版本以上重复点菜单报错问题
const originalPush = Router.prototype.push
Router.prototype.push = function push(location) {
return originalPush.call(this, location).catch(err => err)
}