You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

102 lines
1.7 KiB

---
order: 8
title:
zh-CN: 带页签的卡片
en-US: With tabs
---
## zh-CN
可承载更多内容。
## en-US
More content can be hosted.
```jsx
import { Card } from 'antd';
const tabList = [
{
key: 'tab1',
tab: 'tab1',
},
{
key: 'tab2',
tab: 'tab2',
},
];
const contentList = {
tab1: <p>content1</p>,
tab2: <p>content2</p>,
};
const tabListNoTitle = [
{
key: 'article',
tab: 'article',
},
{
key: 'app',
tab: 'app',
},
{
key: 'project',
tab: 'project',
},
];
const contentListNoTitle = {
article: <p>article content</p>,
app: <p>app content</p>,
project: <p>project content</p>,
};
class TabsCard extends React.Component {
state = {
key: 'tab1',
Add the defaultActiveTabKey property for the Card component (#9526) * Add the defaultActiveTabKey property for the Card component (close #8789, #8942) * `activeTabKey` should be added * Improve * Fix large tabs font size, close #9509 * docs: Add TreeSelect[dropdownClassName] * Fix passing dropdownClassName to tree-select * build: update remark-parse requirement to ^5.0.0 (#9545) Updates the requirements on [remark-parse](https://github.com/remarkjs/remark) to permit the latest version. - [Release notes](https://github.com/remarkjs/remark/releases) - [Commits](https://github.com/remarkjs/remark/commits/remark@5.0.0) Signed-off-by: dependabot[bot] &lt;support@dependabot.com&gt; * add Tooltip contextMenu doc * Improve Grid and Layout type definition * fix: focus editor (#9548) * Fix test case for new jsdom (#9527) * Fix test case for new jsdom * use setTimeout as raf in jest jsdom * Fix cancelAnimationFrame * Add comment for facebook/jest#5147 * longer timeout * fix snap * upgrade antd-tools * Update typescript requirement to ~2.7.2 (#9522) Updates the requirements on [typescript](https://github.com/Microsoft/TypeScript) to permit the latest version. - [Release notes](https://github.com/Microsoft/TypeScript/releases) - [Commits](https://github.com/Microsoft/TypeScript/commits/v2.7.2) Signed-off-by: dependabot[bot] &lt;support@dependabot.com&gt; * Fix a ts error * build: update react-slick requirement to ~0.20.0 (#9543) Updates the requirements on [react-slick](https://github.com/akiran/react-slick) to permit the latest version. - [Changelog](https://github.com/akiran/react-slick/blob/master/CHANGELOG.md) - [Commits](https://github.com/akiran/react-slick/commits) Signed-off-by: dependabot[bot] &lt;support@dependabot.com&gt; * Fix test cases * site: fix intersection-observer polyfill * docs: update recommendation * Fix typo WeexPickerProps -&gt; WeekPickerProps (#9564) * use lodash * Fixed typo on Visualization rules (#9575) Style of a navigation should conform to the its level. should be Style of a navigation should conform to its level. * Improve Radio/Checkbox type definition Close #9574 * Remove AbstractCheckboxChangeEvent, fix TS4029 error See https://github.com/Microsoft/TypeScript/issues/9944 * Update index.en-US.md (#9579) * add transitionName from message.config (#9580) * add transitionName from message.config * Update index.en-US.md (#9579) * modify doc * build: update react-virtualized requirement to ~9.18.5 (#9544) Updates the requirements on [react-virtualized](https://github.com/bvaughn/react-virtualized) to permit the latest version. - [Changelog](https://github.com/bvaughn/react-virtualized/blob/master/CHANGELOG.md) - [Commits](https://github.com/bvaughn/react-virtualized/commits/9.18.5) Signed-off-by: dependabot[bot] &lt;support@dependabot.com&gt; * When treeNode is disabled, its switcher is highlight and clickabled (#9539) * When treeNode is disabled, its switcher is highlight and clickabled * rc-tree@1.7.11 * Fix moment require (#9528) Fix #9502 * Update snapshot
7 years ago
noTitleKey: 'app',
};
onTabChange = (key, type) => {
console.log(key, type);
this.setState({ [type]: key });
};
render() {
return (
<div>
<Card
style={{ width: '100%' }}
title="Card title"
extra={<a href="#">More</a>}
tabList={tabList}
activeTabKey={this.state.key}
onTabChange={key => {
this.onTabChange(key, 'key');
}}
>
{contentList[this.state.key]}
</Card>
<br />
<br />
<Card
style={{ width: '100%' }}
tabList={tabListNoTitle}
Add the defaultActiveTabKey property for the Card component (#9526) * Add the defaultActiveTabKey property for the Card component (close #8789, #8942) * `activeTabKey` should be added * Improve * Fix large tabs font size, close #9509 * docs: Add TreeSelect[dropdownClassName] * Fix passing dropdownClassName to tree-select * build: update remark-parse requirement to ^5.0.0 (#9545) Updates the requirements on [remark-parse](https://github.com/remarkjs/remark) to permit the latest version. - [Release notes](https://github.com/remarkjs/remark/releases) - [Commits](https://github.com/remarkjs/remark/commits/remark@5.0.0) Signed-off-by: dependabot[bot] &lt;support@dependabot.com&gt; * add Tooltip contextMenu doc * Improve Grid and Layout type definition * fix: focus editor (#9548) * Fix test case for new jsdom (#9527) * Fix test case for new jsdom * use setTimeout as raf in jest jsdom * Fix cancelAnimationFrame * Add comment for facebook/jest#5147 * longer timeout * fix snap * upgrade antd-tools * Update typescript requirement to ~2.7.2 (#9522) Updates the requirements on [typescript](https://github.com/Microsoft/TypeScript) to permit the latest version. - [Release notes](https://github.com/Microsoft/TypeScript/releases) - [Commits](https://github.com/Microsoft/TypeScript/commits/v2.7.2) Signed-off-by: dependabot[bot] &lt;support@dependabot.com&gt; * Fix a ts error * build: update react-slick requirement to ~0.20.0 (#9543) Updates the requirements on [react-slick](https://github.com/akiran/react-slick) to permit the latest version. - [Changelog](https://github.com/akiran/react-slick/blob/master/CHANGELOG.md) - [Commits](https://github.com/akiran/react-slick/commits) Signed-off-by: dependabot[bot] &lt;support@dependabot.com&gt; * Fix test cases * site: fix intersection-observer polyfill * docs: update recommendation * Fix typo WeexPickerProps -&gt; WeekPickerProps (#9564) * use lodash * Fixed typo on Visualization rules (#9575) Style of a navigation should conform to the its level. should be Style of a navigation should conform to its level. * Improve Radio/Checkbox type definition Close #9574 * Remove AbstractCheckboxChangeEvent, fix TS4029 error See https://github.com/Microsoft/TypeScript/issues/9944 * Update index.en-US.md (#9579) * add transitionName from message.config (#9580) * add transitionName from message.config * Update index.en-US.md (#9579) * modify doc * build: update react-virtualized requirement to ~9.18.5 (#9544) Updates the requirements on [react-virtualized](https://github.com/bvaughn/react-virtualized) to permit the latest version. - [Changelog](https://github.com/bvaughn/react-virtualized/blob/master/CHANGELOG.md) - [Commits](https://github.com/bvaughn/react-virtualized/commits/9.18.5) Signed-off-by: dependabot[bot] &lt;support@dependabot.com&gt; * When treeNode is disabled, its switcher is highlight and clickabled (#9539) * When treeNode is disabled, its switcher is highlight and clickabled * rc-tree@1.7.11 * Fix moment require (#9528) Fix #9502 * Update snapshot
7 years ago
activeTabKey={this.state.noTitleKey}
tabBarExtraContent={<a href="#">More</a>}
onTabChange={key => {
this.onTabChange(key, 'noTitleKey');
}}
>
{contentListNoTitle[this.state.noTitleKey]}
</Card>
</div>
);
}
}
ReactDOM.render(<TabsCard />, mountNode);
```