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
|
|
|
|
|
|
|
```jsx
|
2018-07-10 21:17:19 +08:00
|
|
|
import { Drawer, Button } from 'antd';
|
2018-06-30 12:32:55 +08:00
|
|
|
|
2018-07-10 21:17:19 +08:00
|
|
|
class App extends React.Component {
|
2018-06-30 12:32:55 +08:00
|
|
|
state = { visible: false, childrenDrawer: false };
|
2018-07-04 08:29:42 +08:00
|
|
|
|
2018-06-30 12:32:55 +08:00
|
|
|
showDrawer = () => {
|
|
|
|
this.setState({
|
|
|
|
visible: true,
|
|
|
|
});
|
|
|
|
};
|
2018-07-04 08:29:42 +08:00
|
|
|
|
2018-06-30 12:32:55 +08:00
|
|
|
onClose = () => {
|
|
|
|
this.setState({
|
|
|
|
visible: false,
|
|
|
|
});
|
|
|
|
};
|
2018-07-04 08:29:42 +08:00
|
|
|
|
2018-06-30 12:32:55 +08:00
|
|
|
showChildrenDrawer = () => {
|
|
|
|
this.setState({
|
|
|
|
childrenDrawer: true,
|
|
|
|
});
|
|
|
|
};
|
2018-07-04 08:29:42 +08:00
|
|
|
|
2018-06-30 12:32:55 +08:00
|
|
|
onChildrenDrawerClose = () => {
|
|
|
|
this.setState({
|
|
|
|
childrenDrawer: false,
|
|
|
|
});
|
|
|
|
};
|
2018-07-04 08:29:42 +08:00
|
|
|
|
2018-06-30 12:32:55 +08:00
|
|
|
render() {
|
|
|
|
return (
|
|
|
|
<div>
|
|
|
|
<Button type="primary" onClick={this.showDrawer}>
|
2018-07-10 21:17:19 +08:00
|
|
|
Open drawer
|
2018-06-30 12:32:55 +08:00
|
|
|
</Button>
|
|
|
|
<Drawer
|
2018-07-10 21:17:19 +08:00
|
|
|
title="Multi-level drawer"
|
2018-06-30 12:32:55 +08:00
|
|
|
width={520}
|
|
|
|
closable={false}
|
|
|
|
onClose={this.onClose}
|
|
|
|
visible={this.state.visible}
|
|
|
|
>
|
2018-07-10 21:17:19 +08:00
|
|
|
<Button type="primary" onClick={this.showChildrenDrawer}>
|
2018-08-05 14:28:39 +08:00
|
|
|
Two-level drawer
|
2018-07-10 21:17:19 +08:00
|
|
|
</Button>
|
2018-06-30 12:32:55 +08:00
|
|
|
<Drawer
|
2018-07-22 11:27:48 +08:00
|
|
|
title="Two-level Drawer"
|
2018-06-30 12:32:55 +08:00
|
|
|
width={320}
|
|
|
|
closable={false}
|
|
|
|
onClose={this.onChildrenDrawerClose}
|
|
|
|
visible={this.state.childrenDrawer}
|
|
|
|
>
|
2018-07-10 21:17:19 +08:00
|
|
|
This is two-level drawer
|
2018-06-30 12:32:55 +08:00
|
|
|
</Drawer>
|
|
|
|
<div
|
|
|
|
style={{
|
|
|
|
position: 'absolute',
|
|
|
|
bottom: 0,
|
|
|
|
width: '100%',
|
|
|
|
borderTop: '1px solid #e8e8e8',
|
|
|
|
padding: '10px 16px',
|
|
|
|
textAlign: 'right',
|
|
|
|
left: 0,
|
|
|
|
background: '#fff',
|
|
|
|
borderRadius: '0 0 4px 4px',
|
|
|
|
}}
|
|
|
|
>
|
|
|
|
<Button
|
|
|
|
style={{
|
|
|
|
marginRight: 8,
|
|
|
|
}}
|
|
|
|
onClick={this.onClose}
|
|
|
|
>
|
|
|
|
Cancel
|
|
|
|
</Button>
|
|
|
|
<Button onClick={this.onClose} type="primary">
|
|
|
|
Submit
|
|
|
|
</Button>
|
|
|
|
</div>
|
|
|
|
</Drawer>
|
|
|
|
</div>
|
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-07-02 12:27:06 +08:00
|
|
|
ReactDOM.render(<App />, mountNode);
|
2018-06-30 12:32:55 +08:00
|
|
|
```
|