2018-11-23 13:39:33 +08:00
|
|
|
---
|
|
|
|
order: 99
|
|
|
|
debug: true
|
|
|
|
title:
|
2019-05-27 19:57:14 +08:00
|
|
|
zh-CN: 嵌套
|
2018-11-23 13:39:33 +08:00
|
|
|
en-US: Nest
|
|
|
|
---
|
|
|
|
|
|
|
|
## zh-CN
|
|
|
|
|
|
|
|
默认选中第一项。
|
|
|
|
|
|
|
|
## en-US
|
|
|
|
|
|
|
|
Default activate first tab.
|
|
|
|
|
2022-05-19 09:46:26 +08:00
|
|
|
```tsx
|
2022-05-23 14:37:16 +08:00
|
|
|
import { Select, Tabs } from 'antd';
|
2022-05-19 09:46:26 +08:00
|
|
|
import React, { useState } from 'react';
|
2018-11-23 13:39:33 +08:00
|
|
|
|
2019-05-27 21:32:45 +08:00
|
|
|
const { Option } = Select;
|
2018-11-23 13:39:33 +08:00
|
|
|
|
|
|
|
const positionList = ['left', 'right', 'top', 'bottom'];
|
|
|
|
|
2022-05-19 09:46:26 +08:00
|
|
|
const App: React.FC = () => {
|
|
|
|
const [parentPos, setParentPos] = useState(undefined);
|
|
|
|
const [childPos, setChildPos] = useState(undefined);
|
|
|
|
const [parentType, setParentType] = useState(undefined);
|
|
|
|
const [childType, setChildType] = useState(undefined);
|
|
|
|
|
|
|
|
return (
|
|
|
|
<div>
|
|
|
|
<Select
|
|
|
|
style={{ width: 200 }}
|
|
|
|
onChange={val => {
|
|
|
|
setParentPos(val);
|
|
|
|
}}
|
|
|
|
>
|
|
|
|
{positionList.map(pos => (
|
|
|
|
<Option key={pos} value={pos}>
|
|
|
|
Parent - {pos}
|
|
|
|
</Option>
|
|
|
|
))}
|
|
|
|
</Select>
|
|
|
|
|
|
|
|
<Select
|
|
|
|
style={{ width: 200 }}
|
|
|
|
onChange={val => {
|
|
|
|
setChildPos(val);
|
|
|
|
}}
|
|
|
|
>
|
|
|
|
{positionList.map(pos => (
|
|
|
|
<Option key={pos} value={pos}>
|
|
|
|
Child - {pos}
|
|
|
|
</Option>
|
|
|
|
))}
|
|
|
|
</Select>
|
|
|
|
|
|
|
|
<Select
|
|
|
|
style={{ width: 200 }}
|
|
|
|
onChange={val => {
|
|
|
|
setParentType(val);
|
|
|
|
}}
|
|
|
|
>
|
|
|
|
<Option value="line">Parent - line</Option>
|
|
|
|
<Option value="card">Parent - card</Option>
|
|
|
|
<Option value="editable-card">Parent - card edit</Option>
|
|
|
|
</Select>
|
|
|
|
|
|
|
|
<Select
|
|
|
|
style={{ width: 200 }}
|
|
|
|
onChange={val => {
|
|
|
|
setChildType(val);
|
|
|
|
}}
|
|
|
|
>
|
|
|
|
<Option value="line">Child - line</Option>
|
|
|
|
<Option value="card">Child - card</Option>
|
|
|
|
<Option value="editable-card">Parent - card edit</Option>
|
|
|
|
</Select>
|
|
|
|
|
2022-08-05 10:49:08 +08:00
|
|
|
<Tabs
|
|
|
|
defaultActiveKey="1"
|
|
|
|
tabPosition={parentPos}
|
|
|
|
type={parentType}
|
|
|
|
items={[
|
|
|
|
{
|
|
|
|
label: 'Tab 1',
|
|
|
|
key: '1',
|
|
|
|
children: (
|
|
|
|
<Tabs
|
|
|
|
defaultActiveKey="1"
|
|
|
|
tabPosition={childPos}
|
|
|
|
type={childType}
|
|
|
|
style={{ height: 300 }}
|
|
|
|
items={new Array(20).fill(null).map((_, index) => {
|
|
|
|
const key = String(index);
|
|
|
|
|
|
|
|
return {
|
|
|
|
label: `Tab ${key}`,
|
|
|
|
key,
|
|
|
|
children: `TTTT ${key}`,
|
|
|
|
};
|
|
|
|
})}
|
|
|
|
/>
|
|
|
|
),
|
|
|
|
},
|
|
|
|
{
|
|
|
|
label: 'Tab 2',
|
|
|
|
key: '2',
|
|
|
|
children: 'Content of Tab Pane 2',
|
|
|
|
},
|
|
|
|
]}
|
|
|
|
/>
|
2022-05-19 09:46:26 +08:00
|
|
|
</div>
|
|
|
|
);
|
|
|
|
};
|
|
|
|
|
|
|
|
export default App;
|
2019-05-07 14:57:32 +08:00
|
|
|
```
|