欢迎来到蕾蕾的博客

Vue 路由跳转报错 Error: Avoided redundant navigation to current location: "/XXX".

在router文件夹下的index.js中加入红色字体代码即可解决

 

import Vue from 'vue'
import VueRouter from 'vue-router'

Vue.use(VueRouter)

const routes = [
{
path: '/',
name: 'Login',
component: () => import('../views/Login.vue')
},
{
path: '/login',
name: 'Login',
component: () => import('../views/Login.vue')
},
{
path: '/home',
name: 'Home',
component: () => import('../views/Home.vue')
}
]

const router = new VueRouter({
routes
})

const originalPush = VueRouter.prototype.push
VueRouter.prototype.push = function push(location) {
return originalPush.call(this, location).catch(err => err)
}

export default router

posted @ 2020-08-14 09:01  蕾蕾是个程序员  阅读(402)  评论(0编辑  收藏  举报