mirror of
https://github.com/ant-design/ant-design.git
synced 2025-01-19 06:43:16 +08:00
修复Breadcrumb.tsx 中处理route.children 路径不对
<Menu.Item key={child.breadcrumbName || child.path}> {itemRender(child, params, routes, [...paths, this.getPath(child.path, params)])} </Menu.Item> itemRender(...args) 中路径应该到拼接当前child.path
This commit is contained in:
parent
abb8692b59
commit
3122f3b86b
@ -70,6 +70,15 @@ export default class Breadcrumb extends React.Component<BreadcrumbProps, any> {
|
||||
'see: https://u.ant.design/item-render.',
|
||||
);
|
||||
}
|
||||
|
||||
getPath = (path, params) => {
|
||||
path = (path || '').replace(/^\//, '');
|
||||
Object.keys(params).forEach(key => {
|
||||
path = path.replace(`:${key}`, params[key]);
|
||||
});
|
||||
return path;
|
||||
}
|
||||
|
||||
genForRoutes = ({
|
||||
routes = [],
|
||||
params = {},
|
||||
@ -78,11 +87,7 @@ export default class Breadcrumb extends React.Component<BreadcrumbProps, any> {
|
||||
}: BreadcrumbProps) => {
|
||||
const paths: string[] = [];
|
||||
return routes.map(route => {
|
||||
route.path = route.path || '';
|
||||
let path = route.path.replace(/^\//, '');
|
||||
Object.keys(params).forEach(key => {
|
||||
path = path.replace(`:${key}`, params[key]);
|
||||
});
|
||||
let path = this.getPath(route.path, params);
|
||||
|
||||
if (path) {
|
||||
paths.push(path);
|
||||
@ -94,7 +99,7 @@ export default class Breadcrumb extends React.Component<BreadcrumbProps, any> {
|
||||
<Menu>
|
||||
{route.children.map(child => (
|
||||
<Menu.Item key={child.breadcrumbName || child.path}>
|
||||
{itemRender(child, params, routes, paths)}
|
||||
{itemRender(child, params, routes, [...paths, this.getPath(child.path, params)])}
|
||||
</Menu.Item>
|
||||
))}
|
||||
</Menu>
|
||||
|
Loading…
Reference in New Issue
Block a user