Commit e618d4d1 authored by ddcat1115's avatar ddcat1115

PageHeader support tabDefaultActiveKey

parent d44f8af4
...@@ -10,6 +10,7 @@ export interface IPageHeaderProps { ...@@ -10,6 +10,7 @@ export interface IPageHeaderProps {
breadcrumbList?: Array<{ title: React.ReactNode; href?: string }>; breadcrumbList?: Array<{ title: React.ReactNode; href?: string }>;
tabList?: Array<{ key: string; tab: React.ReactNode }>; tabList?: Array<{ key: string; tab: React.ReactNode }>;
tabActiveKey?: string; tabActiveKey?: string;
tabDefaultActiveKey?: string;
onTabChange?: (key: string) => void; onTabChange?: (key: string) => void;
tabBarExtraContent?: React.ReactNode; tabBarExtraContent?: React.ReactNode;
linkElement?: React.ReactNode; linkElement?: React.ReactNode;
......
...@@ -166,18 +166,15 @@ export default class PageHeader extends PureComponent { ...@@ -166,18 +166,15 @@ export default class PageHeader extends PureComponent {
tabList, tabList,
className, className,
tabActiveKey, tabActiveKey,
tabDefaultActiveKey,
tabBarExtraContent, tabBarExtraContent,
} = this.props; } = this.props;
const clsString = classNames(styles.pageHeader, className); 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 breadcrumb = this.conversionBreadcrumbList();
const activeKeyProps = { const activeKeyProps = {};
defaultActiveKey: tabDefaultValue && tabDefaultValue.key, if (tabDefaultActiveKey !== undefined) {
}; activeKeyProps.defaultActiveKey = tabDefaultActiveKey;
}
if (tabActiveKey !== undefined) { if (tabActiveKey !== undefined) {
activeKeyProps.activeKey = tabActiveKey; activeKeyProps.activeKey = tabActiveKey;
} }
......
...@@ -25,6 +25,7 @@ order: 11 ...@@ -25,6 +25,7 @@ order: 11
| breadcrumbNameMap | 面包屑相关属性,路由的地址-名称映射表 | object | - | | breadcrumbNameMap | 面包屑相关属性,路由的地址-名称映射表 | object | - |
| tabList | tab 标题列表 | array<{key: string, tab: ReactNode}> | - | | tabList | tab 标题列表 | array<{key: string, tab: ReactNode}> | - |
| tabActiveKey | 当前高亮的 tab 项 | string | - | | tabActiveKey | 当前高亮的 tab 项 | string | - |
| tabDefaultActiveKey | 默认高亮的 tab 项 | string | 第一项 |
| onTabChange | 切换面板的回调 | (key) => void | - | | onTabChange | 切换面板的回调 | (key) => void | - |
| linkElement | 定义链接的元素,默认为 `a`,可传入 react-router 的 Link | string\|ReactElement | - | | linkElement | 定义链接的元素,默认为 `a`,可传入 react-router 的 Link | string\|ReactElement | - |
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment