2018-11-23 13:39:33 +08:00
|
|
|
---
|
|
|
|
order: 99
|
|
|
|
debug: true
|
|
|
|
title:
|
|
|
|
zh-CN: 基本
|
|
|
|
en-US: Nest
|
|
|
|
---
|
|
|
|
|
|
|
|
## zh-CN
|
|
|
|
|
|
|
|
默认选中第一项。
|
|
|
|
|
|
|
|
## en-US
|
|
|
|
|
|
|
|
Default activate first tab.
|
|
|
|
|
2019-05-07 14:57:32 +08:00
|
|
|
```jsx
|
2018-11-23 13:39:33 +08:00
|
|
|
import { Tabs, Select } from 'antd';
|
|
|
|
|
|
|
|
const TabPane = Tabs.TabPane;
|
|
|
|
const Option = Select.Option;
|
|
|
|
|
|
|
|
const positionList = ['left', 'right', 'top', 'bottom'];
|
|
|
|
|
|
|
|
const list = new Array(20).fill().map((_, index) => index);
|
|
|
|
|
|
|
|
class Demo extends React.Component {
|
|
|
|
state = {
|
|
|
|
parentPos: undefined,
|
|
|
|
childPos: undefined,
|
|
|
|
parentType: undefined,
|
|
|
|
childType: undefined,
|
|
|
|
};
|
|
|
|
|
|
|
|
render() {
|
2019-05-07 14:57:32 +08:00
|
|
|
const { parentPos, childPos, parentType, childType } = this.state;
|
2018-11-23 13:39:33 +08:00
|
|
|
|
|
|
|
return (
|
|
|
|
<div>
|
2019-05-07 14:57:32 +08:00
|
|
|
<Select
|
|
|
|
style={{ width: 200 }}
|
|
|
|
onChange={val => {
|
|
|
|
this.setState({ parentPos: val });
|
|
|
|
}}
|
|
|
|
>
|
2018-11-23 13:39:33 +08:00
|
|
|
{positionList.map(pos => (
|
2019-05-07 14:57:32 +08:00
|
|
|
<Option key={pos} value={pos}>
|
|
|
|
Parent - {pos}
|
|
|
|
</Option>
|
2018-11-23 13:39:33 +08:00
|
|
|
))}
|
|
|
|
</Select>
|
|
|
|
|
2019-05-07 14:57:32 +08:00
|
|
|
<Select
|
|
|
|
style={{ width: 200 }}
|
|
|
|
onChange={val => {
|
|
|
|
this.setState({ childPos: val });
|
|
|
|
}}
|
|
|
|
>
|
2018-11-23 13:39:33 +08:00
|
|
|
{positionList.map(pos => (
|
2019-05-07 14:57:32 +08:00
|
|
|
<Option key={pos} value={pos}>
|
|
|
|
Child - {pos}
|
|
|
|
</Option>
|
2018-11-23 13:39:33 +08:00
|
|
|
))}
|
|
|
|
</Select>
|
|
|
|
|
2019-05-07 14:57:32 +08:00
|
|
|
<Select
|
|
|
|
style={{ width: 200 }}
|
|
|
|
onChange={val => {
|
|
|
|
this.setState({ parentType: val });
|
|
|
|
}}
|
|
|
|
>
|
2018-11-23 13:39:33 +08:00
|
|
|
<Option value="line">Parent - line</Option>
|
|
|
|
<Option value="card">Parent - card</Option>
|
|
|
|
</Select>
|
|
|
|
|
2019-05-07 14:57:32 +08:00
|
|
|
<Select
|
|
|
|
style={{ width: 200 }}
|
|
|
|
onChange={val => {
|
|
|
|
this.setState({ childType: val });
|
|
|
|
}}
|
|
|
|
>
|
2018-11-23 13:39:33 +08:00
|
|
|
<Option value="line">Child - line</Option>
|
|
|
|
<Option value="card">Child - card</Option>
|
|
|
|
</Select>
|
|
|
|
|
|
|
|
<Tabs defaultActiveKey="1" tabPosition={parentPos} type={parentType}>
|
|
|
|
<TabPane tab="Tab 1" key="1">
|
2019-05-07 14:57:32 +08:00
|
|
|
<Tabs
|
|
|
|
defaultActiveKey="1"
|
|
|
|
tabPosition={childPos}
|
|
|
|
type={childType}
|
|
|
|
style={{ height: 300 }}
|
|
|
|
>
|
2018-11-23 13:39:33 +08:00
|
|
|
{list.map(key => (
|
2019-05-07 14:57:32 +08:00
|
|
|
<TabPane tab={`Tab ${key}`} key={key}>
|
|
|
|
TTTT {key}
|
|
|
|
</TabPane>
|
2018-11-23 13:39:33 +08:00
|
|
|
))}
|
|
|
|
</Tabs>
|
|
|
|
</TabPane>
|
2019-05-07 14:57:32 +08:00
|
|
|
<TabPane tab="Tab 2" key="2">
|
|
|
|
Content of Tab Pane 2
|
|
|
|
</TabPane>
|
2018-11-23 13:39:33 +08:00
|
|
|
</Tabs>
|
|
|
|
</div>
|
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-05-07 14:57:32 +08:00
|
|
|
ReactDOM.render(<Demo />, mountNode);
|
|
|
|
```
|