zl程序教程

您现在的位置是:首页 >  工具

当前栏目

解决VueRoter/element-ui路由报错Error: Avoided redundant navigation to current location的问题

路由UI 解决 报错 Error to Element Location
2023-09-14 08:57:24 时间

解决ElementUI导航栏重复点菜单报错问题 - 小黑电脑 

http://www.xiaoheidiannao.com/9264.html

 

在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