2018-06-30 12:32:55 +08:00
|
|
|
---
|
|
|
|
order: 5
|
|
|
|
title:
|
|
|
|
zh-CN: 多层抽屉
|
|
|
|
en-US: Multi-level drawer
|
|
|
|
---
|
|
|
|
|
|
|
|
## zh-CN
|
|
|
|
|
|
|
|
在抽屉内打开新的抽屉,用以解决多分支任务的复杂状况。
|
|
|
|
|
|
|
|
## en-US
|
|
|
|
|
2019-04-19 20:59:45 +08:00
|
|
|
Open a new drawer on top of an existing drawer to handle multi branch tasks.
|
2018-06-30 12:32:55 +08:00
|
|
|
|
2022-05-19 09:46:26 +08:00
|
|
|
```tsx
|
2022-05-23 14:37:16 +08:00
|
|
|
import { Button, Drawer } from 'antd';
|
2022-05-19 09:46:26 +08:00
|
|
|
import React, { useState } from 'react';
|
2018-06-30 12:32:55 +08:00
|
|
|
|
2022-05-19 09:46:26 +08:00
|
|
|
const App: React.FC = () => {
|
2022-08-23 14:52:37 +08:00
|
|
|
const [open, setOpen] = useState(false);
|
2022-05-19 09:46:26 +08:00
|
|
|
const [childrenDrawer, setChildrenDrawer] = useState(false);
|
2018-07-04 08:29:42 +08:00
|
|
|
|
2022-05-14 16:40:42 +08:00
|
|
|
const showDrawer = () => {
|
2022-08-23 14:52:37 +08:00
|
|
|
setOpen(true);
|
2018-06-30 12:32:55 +08:00
|
|
|
};
|
2018-07-04 08:29:42 +08:00
|
|
|
|
2022-05-14 16:40:42 +08:00
|
|
|
const onClose = () => {
|
2022-08-23 14:52:37 +08:00
|
|
|
setOpen(false);
|
2018-06-30 12:32:55 +08:00
|
|
|
};
|
2018-07-04 08:29:42 +08:00
|
|
|
|
2022-05-14 16:40:42 +08:00
|
|
|
const showChildrenDrawer = () => {
|
|
|
|
setChildrenDrawer(true);
|
2018-06-30 12:32:55 +08:00
|
|
|
};
|
2018-07-04 08:29:42 +08:00
|
|
|
|
2022-05-14 16:40:42 +08:00
|
|
|
const onChildrenDrawerClose = () => {
|
|
|
|
setChildrenDrawer(false);
|
2018-06-30 12:32:55 +08:00
|
|
|
};
|
2018-07-04 08:29:42 +08:00
|
|
|
|
2022-05-14 16:40:42 +08:00
|
|
|
return (
|
|
|
|
<>
|
|
|
|
<Button type="primary" onClick={showDrawer}>
|
|
|
|
Open drawer
|
|
|
|
</Button>
|
2022-08-23 14:52:37 +08:00
|
|
|
<Drawer title="Multi-level drawer" width={520} closable={false} onClose={onClose} open={open}>
|
2022-05-14 16:40:42 +08:00
|
|
|
<Button type="primary" onClick={showChildrenDrawer}>
|
|
|
|
Two-level drawer
|
2018-06-30 12:32:55 +08:00
|
|
|
</Button>
|
|
|
|
<Drawer
|
2022-05-14 16:40:42 +08:00
|
|
|
title="Two-level Drawer"
|
|
|
|
width={320}
|
2018-06-30 12:32:55 +08:00
|
|
|
closable={false}
|
2022-05-14 16:40:42 +08:00
|
|
|
onClose={onChildrenDrawerClose}
|
2022-08-23 14:52:37 +08:00
|
|
|
open={childrenDrawer}
|
2018-06-30 12:32:55 +08:00
|
|
|
>
|
2022-05-14 16:40:42 +08:00
|
|
|
This is two-level drawer
|
2018-06-30 12:32:55 +08:00
|
|
|
</Drawer>
|
2022-05-14 16:40:42 +08:00
|
|
|
</Drawer>
|
|
|
|
</>
|
|
|
|
);
|
|
|
|
};
|
2022-05-19 09:46:26 +08:00
|
|
|
|
|
|
|
export default App;
|
2018-06-30 12:32:55 +08:00
|
|
|
```
|
2019-12-25 18:06:50 +08:00
|
|
|
|
|
|
|
<style>
|
|
|
|
[data-theme="dark"] .site-multi-level-drawer-footer {
|
|
|
|
border-top: 1px solid #303030;
|
|
|
|
background: #1f1f1f;
|
|
|
|
}
|
|
|
|
</style>
|