-
-
Notifications
You must be signed in to change notification settings - Fork 8.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
自定义布局及路由问题 #11078
Comments
我遇到同样的问题,请问有没有解决这个问题呢? |
@wuchencm 我解决了你这个问题,现在需要使用来代替{props.children}了 |
是的,Outlet确实可以,但是怎么才能将routes里定义的路由信息呢 |
根据你提供的代码和问题描述,看起来你希望在自定义布局文件中使用 要解决此问题,你可以取消注释 const menuDataRender = () => {
// 获取routes配置中的数据
const routes = [
{
path: "/",
name: "首页",
icon: "home",
routes: [
{
path: "/dashboard",
name: "Dashboard",
},
// 其他路由配置...
],
},
// 其他顶级路由配置...
];
// 处理路由数据,生成菜单数据
const formatMenuData = (routes) => {
return routes.map((route) => {
const { path, name, icon, routes: subRoutes } = route;
const menuData = {
path,
name,
icon,
};
// 如果有子路由,递归处理子路由
if (subRoutes && subRoutes.length > 0) {
menuData.routes = formatMenuData(subRoutes);
}
return menuData;
});
};
return formatMenuData(routes);
}; 然后在 <ProLayout
{...props}
logo={false}
title={false}
layout="mix"
headerRender={false}
menuDataRender={menuDataRender}
>
{props.children}
</ProLayout> 这样就可以让自定义布局文件根据 |
目前使用的是ant design pro v6的版本,想实现一个自定义布局的功能
这是我的自定义布局的代码
`
const CustomLayout: React.FC = (props) => {
// const menuDataRender = () => [
// {
// name:'概览',
// path:'/appstack/app/:appName/overview',
// component: './AppStack/index.tsx',
// },
// {
// name:'研发流程',
// path:'/appstack/app/:appName/workflow',
// component: './AppStack/index.tsx',
// },
// {
// name:'变更',
// path:'/appstack/app/:appName/changes',
// component: './AppStack/index.tsx',
// },
// {
// name:'环境',
// path:'/appstack/app/:appName/envs',
// component: './AppStack/index.tsx',
// },
// ];
}`
这是我的routes.ts 配置:
遇到的问题是:
这个菜单数据在自定义布局文件中配置的话是可以展示的,难道不能接收routes里的数据吗?
The text was updated successfully, but these errors were encountered: