mirror of
https://github.com/ant-design/ant-design.git
synced 2024-11-29 13:47:02 +08:00
1919b5f7d9
Co-authored-by: 二货机器人 <smith3816@gmail.com>
72 lines
1.4 KiB
Markdown
72 lines
1.4 KiB
Markdown
---
|
|
order: 5
|
|
title:
|
|
zh-CN: 多层抽屉
|
|
en-US: Multi-level drawer
|
|
---
|
|
|
|
## zh-CN
|
|
|
|
在抽屉内打开新的抽屉,用以解决多分支任务的复杂状况。
|
|
|
|
## en-US
|
|
|
|
Open a new drawer on top of an existing drawer to handle multi branch tasks.
|
|
|
|
```tsx
|
|
import { Button, Drawer } from 'antd';
|
|
import React, { useState } from 'react';
|
|
|
|
const App: React.FC = () => {
|
|
const [open, setOpen] = useState(false);
|
|
const [childrenDrawer, setChildrenDrawer] = useState(false);
|
|
|
|
const showDrawer = () => {
|
|
setOpen(true);
|
|
};
|
|
|
|
const onClose = () => {
|
|
setOpen(false);
|
|
};
|
|
|
|
const showChildrenDrawer = () => {
|
|
setChildrenDrawer(true);
|
|
};
|
|
|
|
const onChildrenDrawerClose = () => {
|
|
setChildrenDrawer(false);
|
|
};
|
|
|
|
return (
|
|
<>
|
|
<Button type="primary" onClick={showDrawer}>
|
|
Open drawer
|
|
</Button>
|
|
<Drawer title="Multi-level drawer" width={520} closable={false} onClose={onClose} open={open}>
|
|
<Button type="primary" onClick={showChildrenDrawer}>
|
|
Two-level drawer
|
|
</Button>
|
|
<Drawer
|
|
title="Two-level Drawer"
|
|
width={320}
|
|
closable={false}
|
|
onClose={onChildrenDrawerClose}
|
|
open={childrenDrawer}
|
|
>
|
|
This is two-level drawer
|
|
</Drawer>
|
|
</Drawer>
|
|
</>
|
|
);
|
|
};
|
|
|
|
export default App;
|
|
```
|
|
|
|
<style>
|
|
[data-theme="dark"] .site-multi-level-drawer-footer {
|
|
border-top: 1px solid #303030;
|
|
background: #1f1f1f;
|
|
}
|
|
</style>
|