mirror of
https://github.com/ant-design/ant-design.git
synced 2024-12-04 17:09:46 +08:00
7fd093bd0a
* docs: add general components TS demo * docs: add layout components TS demo * docs: add navigation components TS demo * docs: add data entry components TS demo * chore(deps): add types for qs * docs: add data display TS demo * docs: add feedback components TS demo * docs: add other components TS demo * chore(deps): add types * docs: unified demo code style * docs: fix lint error * docs: add demo TS type * docs: fix demo TS type * test: update snapshot * docs: fix TS demo * feat: update Rate character type * docs: fix lint error * feat: update Rate character type * feat: update Rate character type
109 lines
2.4 KiB
Markdown
109 lines
2.4 KiB
Markdown
---
|
|
order: 99
|
|
debug: true
|
|
title:
|
|
zh-CN: 嵌套
|
|
en-US: Nest
|
|
---
|
|
|
|
## zh-CN
|
|
|
|
默认选中第一项。
|
|
|
|
## en-US
|
|
|
|
Default activate first tab.
|
|
|
|
```tsx
|
|
import React, { useState } from 'react';
|
|
import { Tabs, Select } from 'antd';
|
|
|
|
const { TabPane } = Tabs;
|
|
const { Option } = Select;
|
|
|
|
const positionList = ['left', 'right', 'top', 'bottom'];
|
|
|
|
const list = Array.from({ length: 20 }).map((_, index) => index);
|
|
|
|
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>
|
|
|
|
<Tabs defaultActiveKey="1" tabPosition={parentPos} type={parentType}>
|
|
<TabPane tab="Tab 1" key="1">
|
|
<Tabs
|
|
defaultActiveKey="1"
|
|
tabPosition={childPos}
|
|
type={childType}
|
|
style={{ height: 300 }}
|
|
>
|
|
{list.map(key => (
|
|
<TabPane tab={`Tab ${key}`} key={key}>
|
|
TTTT {key}
|
|
</TabPane>
|
|
))}
|
|
</Tabs>
|
|
</TabPane>
|
|
<TabPane tab="Tab 2" key="2">
|
|
Content of Tab Pane 2
|
|
</TabPane>
|
|
</Tabs>
|
|
</div>
|
|
);
|
|
};
|
|
|
|
export default App;
|
|
```
|