From db197c352e50fbcc3d9896d052caa4433164b504 Mon Sep 17 00:00:00 2001 From: afc163 Date: Thu, 26 Oct 2017 10:43:04 +0800 Subject: [PATCH] fix breadcrumb --- src/components/PageHeader/index.js | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/src/components/PageHeader/index.js b/src/components/PageHeader/index.js index 5fbe3648..7bb8b4e3 100644 --- a/src/components/PageHeader/index.js +++ b/src/components/PageHeader/index.js @@ -59,9 +59,8 @@ export default class PageHeader extends PureComponent { const url = `/${pathSnippets.slice(0, index + 1).join('/')}`; return ( - {createElement(linkElement, { - to: url, - href: url, + {createElement(index === pathSnippets.length - 1 ? 'span' : linkElement, { + [linkElement === 'a' ? 'href' : 'to']: url, }, breadcrumbNameMap[url] || breadcrumbNameMap[url.replace('/', '')] || url)} ); @@ -69,8 +68,7 @@ export default class PageHeader extends PureComponent { const breadcrumbItems = [( {createElement(linkElement, { - to: '/', - href: '/', + [linkElement === 'a' ? 'href' : 'to']: '/', }, '首页')} )].concat(extraBreadcrumbItems); @@ -85,7 +83,11 @@ export default class PageHeader extends PureComponent { { breadcrumbList.map(item => ( - {item.href ? {item.title} : item.title} + {item.href ? ( + createElement(linkElement, { + [linkElement === 'a' ? 'href' : 'to']: item.href, + }, '首页') + ) : item.title} ) ) } -- GitLab