重写默认的路由

  1. <PageHeaderWrapper
  2. className="site-page-header"
  3. title="Title"
  4. subTitle="This is a subtitle"
  5. breadcrumb={
  6. {
  7. routes: [
  8. {
  9. path: 'index',
  10. breadcrumbName: 'First-level Menu',
  11. },
  12. {
  13. path: 'first',
  14. breadcrumbName: 'Second-level Menu',
  15. },
  16. {
  17. path: 'second',
  18. breadcrumbName: 'Third-level Menu',
  19. },
  20. ]
  21. }}
  22. >

PageHeaderWrapper 有 antd PageHeader 所有属性
https://pro.ant.design/docs/layout-component-cn#pageheaderwrapper

https://ant.design/components/page-header-cn/#/index/first

重写面包屑导航

import itemRender from '../../../../utils/breadcrumbRenderLink';

<PageHeaderWrapper
      content="将一个冗长或用户不熟悉的表单任务分成多个步骤,指导用户完成。"
      breadcrumb={{
        itemRender: itemRender,
        routes: [
          {
            path: '/',
            breadcrumbName: '首页',
          },
          {
            path: '/record',
            breadcrumbName: '兑奖记录',
          },
          {
            breadcrumbName: '实物发奖',
          },
        ],
      }}
    >


// breadcrumbRenderLink.js    
import router from 'umi/router';

function itemRender(route, params, routes, paths) {
  const last = routes.indexOf(route) === routes.length - 1;
  const routerJump = (link, paths) => {
    return () => router.push(link)
  }
  return last ? (
    <span>{route.breadcrumbName}</span>
  ) : (
      <span style={{
        cursor: 'pointer'
      }} onClick={routerJump(paths.join('/'), paths)}>{route.breadcrumbName}</span>
    );
}

export default itemRender