diff --git a/src/components/PageHeader/demo/standard.md b/src/components/PageHeader/demo/standard.md
index 8a5c8eded03dd6d4a19888a73e7b90377ca1fb72..5c59c933c282b913b4bb56d69ee915feb56fc29f 100644
--- a/src/components/PageHeader/demo/standard.md
+++ b/src/components/PageHeader/demo/standard.md
@@ -88,6 +88,7 @@ ReactDOM.render(
extraContent={extra}
breadcrumbList={breadcrumbList}
tabList={tabList}
+ tabActiveKey="detail"
onTabChange={onTabChange}
/>
diff --git a/src/components/PageHeader/demo/structure.md b/src/components/PageHeader/demo/structure.md
index 077d6e5c36f32d881bc2c0510061d929588254cf..429eed6319f6f483da6ac724242a07f0626e3f0c 100644
--- a/src/components/PageHeader/demo/structure.md
+++ b/src/components/PageHeader/demo/structure.md
@@ -34,6 +34,7 @@ ReactDOM.render(
extraContent={
extraContent
}
breadcrumbList={breadcrumbList}
tabList={tabList}
+ tabActiveKey="1"
/>
, mountNode);
diff --git a/src/components/PageHeader/index.d.ts b/src/components/PageHeader/index.d.ts
index 8ca909223fbaae544d98980b83fdd4ece915597d..ca2cf565d8eba282f07ea785219c6bf17856c17a 100644
--- a/src/components/PageHeader/index.d.ts
+++ b/src/components/PageHeader/index.d.ts
@@ -9,6 +9,7 @@ export interface PageHeaderProps {
params?: any;
breadcrumbList?: Array<{ title: React.ReactNode; href?: string }>;
tabList?: Array<{ key: string; tab: React.ReactNode }>;
+ tabActiveKey?: string;
onTabChange?: (key: string) => void;
linkElement?: React.ReactNode;
}
diff --git a/src/components/PageHeader/index.js b/src/components/PageHeader/index.js
index eb0318b1bbe144608dbccac605d9ee699628913d..8680585eb4e6e9871d3dd050c0a3a2fcc1a78c99 100644
--- a/src/components/PageHeader/index.js
+++ b/src/components/PageHeader/index.js
@@ -60,6 +60,7 @@ export default class PageHeader extends PureComponent {
const {
title, logo, action, content, extraContent,
breadcrumbList, tabList, className, linkElement = 'a',
+ activeTabKey,
} = this.props;
const clsString = classNames(styles.pageHeader, className);
let breadcrumb;
@@ -120,7 +121,10 @@ export default class PageHeader extends PureComponent {
breadcrumb = null;
}
- const tabDefaultValue = tabList && (tabList.filter(item => item.default)[0] || tabList[0]);
+ let tabDefaultValue;
+ if (activeTabKey !== undefined && tabList) {
+ tabDefaultValue = tabList.filter(item => item.default)[0] || tabList[0];
+ }
return (
@@ -144,6 +148,7 @@ export default class PageHeader extends PureComponent {
{
diff --git a/src/components/PageHeader/index.md b/src/components/PageHeader/index.md
index cd018c38412d179df9659285ca894d392e110a91..b150039070a45724ddbc374360514389b83451f4 100644
--- a/src/components/PageHeader/index.md
+++ b/src/components/PageHeader/index.md
@@ -22,6 +22,7 @@ order: 11
| params | 面包屑相关属性,路由的参数 | object | - |
| breadcrumbList | 面包屑数据,配置了 `routes` `params` 时此属性无效 | array<{title: ReactNode, href?: string}> | - |
| tabList | tab 标题列表 | array<{key: string, tab: ReactNode}> | - |
+| tabActiveKey | 当前高亮的 tab 项 | string | - |
| onTabChange | 切换面板的回调 | (key) => void | - |
| linkElement | 定义链接的元素,默认为 `a`,可传入 react-router 的 Link | string\|ReactElement | - |
diff --git a/src/routes/List/List.js b/src/routes/List/List.js
index c35e2ec1e7e80d4f3df7d32b6c1ad5e1ac889a29..e7b10a699123e17d801c44a00fa93e86de536747 100644
--- a/src/routes/List/List.js
+++ b/src/routes/List/List.js
@@ -48,7 +48,7 @@ export default class SearchList extends Component {
);
- const { match, routerData } = this.props;
+ const { match, routerData, location } = this.props;
const routes = getRoutes(match.path, routerData);
return (
@@ -56,6 +56,7 @@ export default class SearchList extends Component {
title="搜索列表"
content={mainSearch}
tabList={tabList}
+ activeTabKey={location.pathname.replace(`${match.path}/`, '')}
onTabChange={this.handleTabChange}
>