umijs / umi

A framework in react community ✨
https://umijs.org
MIT License
15.25k stars 2.65k forks source link

如何动态创建菜单?后台加载 patchRoutes 无效🧐[问题] #8163

Closed hyzx86 closed 2 years ago

hyzx86 commented 2 years ago

What happens?

参考umi 文档操作 https://umijs.org/zh-CN/docs/runtime-config#patchroutes-routes- 修改路由无效,菜单能出来,但打开页面显示404

Mini Showcase Repository(REQUIRED)

Please provide a repository using yarn create @umijs/umi-app then upload to your GitHub 请提供一个可复现的仓库,使用 yarn create @umijs/umi-app 创建,并上传到你的 GitHub 仓库 测试代码如下


export function patchRoutes({ routes }) {
  routes[0].routes[7].routes.push({
    name: 'amisEditor111',
    path: '/editor111',
    locale: false,
    meta: { schemaId: '40emtqq91aqe855bydkj268gx6' },
    component: dynamic({
      loader: () => import(‘./pages/develop/dynamicPage'),
      loading: LoadingComponent,
    }),
  });

  console.log(routes, 'patchRoutespatchRoutes');
  return routes;
}

How To Reproduce

Steps to reproduce the behavior: 1. 2.

Expected behavior 1. 2.

如下截图,组件找到了,但依旧显示404

image

Context

hyzx86 commented 2 years ago

相同的问题 在 antdpro

https://github.com/ant-design/ant-design-pro/issues/9920

frontend-winter commented 2 years ago

刷下页面

hyzx86 commented 2 years ago

刷下页面

没用,据说是不支持动态创建路由,可以创建好规则然后 在规则下使用参数化路由 image

先凑合用了。。