VUE3 router.push({ name: 'XXX', }); 报错Error: No match for {"name":"BpmModelCrea

23 阅读1分钟

完整报错为
Error: No match for {"name":"BpmModelCreate","params":{}}


最开始查询的时候知道报错原因是因为找不到对应路由 但是因为原有路由是通过其他文件引入的 引入时如果出现不兼容的情况下会导致这个问题出现

解决办法 因为页面是部分本地组件页面 所以引入与vue2的路由文件类似 VUE3 中存在 router/local 文件中进行页面配置
const workflow: RouteRecordStringComponent[] = [
  {
    component: '/bpm/form/designer/index',
    name: 'BpmFormEditor',
    path: 'bpm/manager/form/edit',
    meta: {
      activePath: '/bpm/manager/form',
      icon: '',
      title: 'XXX',
      hideInMenu: true,
    },
    props: (route) => {
      return {
        id: route.query.id,
        type: route.query.type,
        copyId: route.query.copyId,
      };
    },
  },
  {
    component: '/bpm/model/form/index',
    name: 'BpmModelCreate',
    path: 'manager/model/create',
    meta: {
      activePath: '/bpm/manager/model',
      icon: 'carbon:flow-connection',
      title: 'XXX',
      hideInMenu: true,
      keepAlive: true,
    },
  },
];

export const localMenuList: RouteRecordStringComponent[] = [
  {
    component: 'BasicLayout',
    meta: {
      order: -1,
      title: 'page.dashboard.title',
      // 不使用基础布局(仅在顶级生效)
      noBasicLayout: true,
    },
    name: 'Dashboard',
    path: '/',
    redirect: '/analytics',
    children: [
      {
        name: 'Analytics',
        path: '/analytics',
        component: '/dashboard/analytics/index',
        meta: {
          affixTab: true,
          title: 'page.dashboard.analytics',
        },
      },
    ],
  },
  ...workflow,
];

通过本地引入的方式直接存放在本地的路由