diff --git a/src/components/PageHeader/index.d.ts b/src/components/PageHeader/index.d.ts index 62d1f8802ee26ba511f82c23713ca293b1dfd8a4..a1c356e7c3c6b9c9adf683fdb73c92cb6a669384 100644 --- a/src/components/PageHeader/index.d.ts +++ b/src/components/PageHeader/index.d.ts @@ -10,6 +10,7 @@ export interface IPageHeaderProps { breadcrumbList?: Array<{ title: React.ReactNode; href?: string }>; tabList?: Array<{ key: string; tab: React.ReactNode }>; tabActiveKey?: string; + tabDefaultActiveKey?: string; onTabChange?: (key: string) => void; tabBarExtraContent?: React.ReactNode; linkElement?: React.ReactNode; diff --git a/src/components/PageHeader/index.js b/src/components/PageHeader/index.js index 644b1e4f31329d0a8b0175a85c899b2fd1afce07..e185f6a79d47510708af03eb529a69d8eafc707e 100644 --- a/src/components/PageHeader/index.js +++ b/src/components/PageHeader/index.js @@ -166,18 +166,15 @@ export default class PageHeader extends PureComponent { tabList, className, tabActiveKey, + tabDefaultActiveKey, tabBarExtraContent, } = this.props; const clsString = classNames(styles.pageHeader, className); - - let tabDefaultValue; - if (tabActiveKey === undefined && tabList) { - tabDefaultValue = tabList.filter(item => item.default)[0] || tabList[0]; - } const breadcrumb = this.conversionBreadcrumbList(); - const activeKeyProps = { - defaultActiveKey: tabDefaultValue && tabDefaultValue.key, - }; + const activeKeyProps = {}; + if (tabDefaultActiveKey !== undefined) { + activeKeyProps.defaultActiveKey = tabDefaultActiveKey; + } if (tabActiveKey !== undefined) { activeKeyProps.activeKey = tabActiveKey; } diff --git a/src/components/PageHeader/index.md b/src/components/PageHeader/index.md index 334d354c84626225581325ef3c6d5ab4e72b631a..288f8b6ccdb2bbea3c0f83faf103aa4adde6694e 100644 --- a/src/components/PageHeader/index.md +++ b/src/components/PageHeader/index.md @@ -25,6 +25,7 @@ order: 11 | breadcrumbNameMap | 面包屑相关属性,路由的地址-名称映射表 | object | - | | tabList | tab 标题列表 | array<{key: string, tab: ReactNode}> | - | | tabActiveKey | 当前高亮的 tab 项 | string | - | +| tabDefaultActiveKey | 默认高亮的 tab 项 | string | 第一项 | | onTabChange | 切换面板的回调 | (key) => void | - | | linkElement | 定义链接的元素,默认为 `a`,可传入 react-router 的 Link | string\|ReactElement | - |