Error: Avoided redundant navigation to current location: “/users”.
问题触发原因:在Vue导航菜单中,重复点击一个菜单,即重复触发一个相同的路由,会报错,但不影响功能
解决:在router的配置文件中加入如下代码
const originalPush = VueRouter.prototype.push
VueRouter.prototype.push = function push(location) {
return originalPush.call(this, location).catch(err => err)
}
加完变成:
Vue.use(VueRouter)
const routes = [{
path: '/', redirect: '/login'
}, {
path: '/login', component: Login
}]
// 解决上述问题
const originalPush = VueRouter.prototype.push
VueRouter.prototype.push = function push(location) {
return originalPush.call(this, location).catch(err => err)
}
const router = new VueRouter({
routes
})
export default router
参考:https://blog.csdn.net/xiecheng1995/article/details/106497172/?utm_medium=distribute.pc_relevant.none-task-blog-baidujs-1