2018-08-10 13:32:33 +08:00
|
|
|
---
|
|
|
|
order: 1
|
|
|
|
title:
|
|
|
|
zh-CN: 自定义位置
|
|
|
|
en-US: Custom Placement
|
|
|
|
---
|
|
|
|
|
|
|
|
## zh-CN
|
|
|
|
|
2021-06-11 08:39:17 +08:00
|
|
|
自定义位置,点击触发按钮抽屉从相应的位置滑出,点击遮罩区关闭。
|
2018-08-10 13:32:33 +08:00
|
|
|
|
|
|
|
## en-US
|
|
|
|
|
2019-04-19 20:59:45 +08:00
|
|
|
The Drawer can appear from any edge of the screen.
|
2018-08-10 13:32:33 +08:00
|
|
|
|
|
|
|
```jsx
|
2020-04-29 16:21:56 +08:00
|
|
|
import { Drawer, Button, Radio, Space } from 'antd';
|
2018-08-10 13:32:33 +08:00
|
|
|
|
|
|
|
class App extends React.Component {
|
|
|
|
state = { visible: false, placement: 'left' };
|
|
|
|
|
|
|
|
showDrawer = () => {
|
|
|
|
this.setState({
|
|
|
|
visible: true,
|
|
|
|
});
|
|
|
|
};
|
|
|
|
|
|
|
|
onClose = () => {
|
|
|
|
this.setState({
|
|
|
|
visible: false,
|
|
|
|
});
|
|
|
|
};
|
|
|
|
|
2019-05-07 14:57:32 +08:00
|
|
|
onChange = e => {
|
2018-08-10 13:32:33 +08:00
|
|
|
this.setState({
|
|
|
|
placement: e.target.value,
|
|
|
|
});
|
2019-05-07 14:57:32 +08:00
|
|
|
};
|
2018-08-10 13:32:33 +08:00
|
|
|
|
|
|
|
render() {
|
2020-05-10 17:15:41 +08:00
|
|
|
const { placement, visible } = this.state;
|
2018-08-10 13:32:33 +08:00
|
|
|
return (
|
2020-05-10 17:15:41 +08:00
|
|
|
<>
|
2020-04-29 16:21:56 +08:00
|
|
|
<Space>
|
2021-06-11 08:39:17 +08:00
|
|
|
<Radio.Group value={placement} onChange={this.onChange}>
|
2020-04-29 16:21:56 +08:00
|
|
|
<Radio value="top">top</Radio>
|
|
|
|
<Radio value="right">right</Radio>
|
|
|
|
<Radio value="bottom">bottom</Radio>
|
|
|
|
<Radio value="left">left</Radio>
|
2020-05-19 18:11:21 +08:00
|
|
|
</Radio.Group>
|
2020-04-29 16:21:56 +08:00
|
|
|
<Button type="primary" onClick={this.showDrawer}>
|
|
|
|
Open
|
|
|
|
</Button>
|
|
|
|
</Space>
|
2018-08-10 13:32:33 +08:00
|
|
|
<Drawer
|
|
|
|
title="Basic Drawer"
|
2020-05-10 17:15:41 +08:00
|
|
|
placement={placement}
|
2018-08-10 13:32:33 +08:00
|
|
|
closable={false}
|
|
|
|
onClose={this.onClose}
|
2020-05-10 17:15:41 +08:00
|
|
|
visible={visible}
|
|
|
|
key={placement}
|
2018-08-10 13:32:33 +08:00
|
|
|
>
|
|
|
|
<p>Some contents...</p>
|
|
|
|
<p>Some contents...</p>
|
|
|
|
<p>Some contents...</p>
|
|
|
|
</Drawer>
|
2020-05-10 17:15:41 +08:00
|
|
|
</>
|
2018-08-10 13:32:33 +08:00
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
ReactDOM.render(<App />, mountNode);
|
|
|
|
```
|