Avoided redundant navigation to current location: “/home”
在VUE中路由遇到Error: Avoided redundant navigation to current location:报错显示是路由重复首先打开我们的路由配置文件,router文件夹下的index.js。在index.js添加如下代码import Vue from 'vue';import VueRouter from 'vue-router';Vue.use(VueRouter);/
·
在VUE中路由遇到Error: Avoided redundant navigation to current location:报错显示是路由重复
- 首先打开我们的路由配置文件,router文件夹下的index.js。
- 在index.js添加如下代码
import Vue from 'vue';
import VueRouter from 'vue-router';
Vue.use(VueRouter);
// 解决ElementUI导航栏中的vue-router在3.0版本以上重复点菜单报错问题
const originalPush = VueRouter.prototype.push
VueRouter.prototype.push = function push(location) {
return originalPush.call(this, location).catch(err => err)
}
- 如果修改了还是没有生效,那么可以尝试replace方法,例如:
const originalReplace = VueRouter.prototype.replace;
Router.prototype.replace = function replace(location) {
return originalReplace.call(this, location).catch(err => err);
};
更多推荐
已为社区贡献2条内容
所有评论(0)