vuerouter路由Avoided redundant navigation to current location Redirected when going from x to x naviga

在使用ElementUI中的导航时,默认情况下如果重复点击某选项,会报错。

element-ui.common.js?b705:3354 Error: Avoided redundant navigation to current location: “/home/home1”.

vuerouter路由Avoided redundant navigation to current location Redirected when going from x to x naviga_第1张图片

问题原因一样 重复访问同一个路由地址 

vuerouter路由Avoided redundant navigation to current location Redirected when going from x to x naviga_第2张图片

可以在router的配置文件中(router -> index.js)加上下面这句话,注意位置:

import Vue from 'vue'
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)
}

......

 

你可能感兴趣的:(Vue,ERROR)