admin管理员组

文章数量:1612098

vue-router 报错Error: Avoided redundant navigation to current location: "/index/user"解决方式

    • 问题描述
    • 解决方式

问题描述

使用element-ui制作的导航菜单,连续点击同一个导航时,报错
该报错不影响功能(… 影响强迫症…)

如图

当前地址 http://localhost:8080/#/index/user
连续点击–用户列表
跳转至同一地址 http://localhost:8080/#/index/user
出现报错

解决方式

import Vue from 'vue'
import VueRouter from 'vue-router'
Vue.use(VueRouter)
// router文件夹-->index.js文件
//cv以下代码解决路由地址重复的报错问题(一劳永逸)
const originalPush = VueRouter.prototype.push
   VueRouter.prototype.push = function push(location) {
   return originalPush.call(this, location).catch(err => err)
}

本文标签: 报错方式ErrorAvoidedrouter