Vue Navigating to current location (“XXXXXX“) is not allowed

问题:

在VUE项目中点击两次路由切换

 原因:

在路由跳转的时候同一个路由多次添加是不被允许的

 解决方案(两种):

1.切换版本回3.0版本

2.在你引了 vue-router 的 js文件里加上如下代码即可

import Vue from 'vue'  //如果已引用,不需要重复引用
import Router from 'vue-router'; //如果已引用,不需要重复引用
Vue.use(Router) //如果已引用,不需要重复引用
const VueRouterPush = Router.prototype.push 
Router.prototype.push = function push (to) {
    return VueRouterPush.call(this, to).catch(err => err)
}

https://www.jianshu.com/p/a140ad42ef00

猜你喜欢

转载自blog.csdn.net/GrootBaby/article/details/107957462