今天在写项目时发现了在点击 路由跳转 会造成报错的问题, 报错内容为: 在这里插入图片描述

在引入 import Router from 'vue-router'文件里面添加如下代码:

const originalPush = Router.prototype.push

Router.prototype.push = function push(location) {

  return originalPush.call(this, location).catch(err => err)

}

解决

但主要原因是使用的element-ui组件跳转路径配置index问题

<el-menu-item-group v-for="(childItem, childIndex) in item.children" :key="childIndex">

        <el-menu-item :index="'/main/'+childItem.menusUrl">{{childItem.menusName}}</el-menu-item>

</el-menu-item-group>

修改 :index路径,完美解决

Logo

前往低代码交流专区

更多推荐