diff --git a/components/card/demo/tabs.md b/components/card/demo/tabs.md index 1de9e3a0f1..09821369a9 100644 --- a/components/card/demo/tabs.md +++ b/components/card/demo/tabs.md @@ -14,6 +14,7 @@ title: More content can be hosted. ```jsx +import React, { useState } from 'react'; import { Card } from 'antd'; const tabList = [ @@ -53,49 +54,47 @@ const contentListNoTitle = { project:

project content

, }; -class TabsCard extends React.Component { - state = { - key: 'tab1', - noTitleKey: 'app', - }; +const TabsCard = () => { + const [activeTabKey1, setActiveTabKey1] = useState('tab1'); + const [activeTabKey2, setActiveTabKey2] = useState('app'); - onTabChange = (key, type) => { - console.log(key, type); - this.setState({ [type]: key }); + const onTab1Change = key => { + setActiveTabKey1(key); + }; + const onTab2Change = key => { + setActiveTabKey2(key); }; - render() { - return ( - <> - More} - tabList={tabList} - activeTabKey={this.state.key} - onTabChange={key => { - this.onTabChange(key, 'key'); - }} - > - {contentList[this.state.key]} - -
-
- More} - onTabChange={key => { - this.onTabChange(key, 'noTitleKey'); - }} - > - {contentListNoTitle[this.state.noTitleKey]} - - - ); - } -} + return ( + <> + More} + tabList={tabList} + activeTabKey={activeTabKey1} + onTabChange={key => { + onTab1Change(key); + }} + > + {contentList[activeTabKey1]} + +
+
+ More} + onTabChange={key => { + onTab2Change(key); + }} + > + {contentListNoTitle[activeTabKey2]} + + + ); +}; ReactDOM.render(, mountNode); ``` diff --git a/components/card/style/index.less b/components/card/style/index.less index 102d100368..7c02be1f4b 100644 --- a/components/card/style/index.less +++ b/components/card/style/index.less @@ -66,7 +66,7 @@ } } - .@{ant-prefix}-tabs { + .@{ant-prefix}-tabs-top { clear: both; margin-bottom: @card-head-tabs-margin-bottom; color: @text-color;