diff --git a/components/breadcrumb/Breadcrumb.tsx b/components/breadcrumb/Breadcrumb.tsx index 8a6a39c765..2bdbdb13b4 100755 --- a/components/breadcrumb/Breadcrumb.tsx +++ b/components/breadcrumb/Breadcrumb.tsx @@ -70,6 +70,15 @@ export default class Breadcrumb extends React.Component { '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) => { 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 { {route.children.map(child => ( - {itemRender(child, params, routes, paths)} + {itemRender(child, params, routes, [...paths, this.getPath(child.path, params)])} ))}