2018-05-23 10:56:37 +08:00
|
|
|
---
|
|
|
|
order: 0
|
|
|
|
title:
|
2018-06-22 15:46:21 +08:00
|
|
|
zh-CN: 基础抽屉
|
2018-05-23 10:56:37 +08:00
|
|
|
en-US: Basic
|
|
|
|
---
|
|
|
|
|
|
|
|
## zh-CN
|
|
|
|
|
2018-06-22 15:46:21 +08:00
|
|
|
基础抽屉,点击触发按钮抽屉从右滑出,点击遮罩区关闭
|
2018-05-23 10:56:37 +08:00
|
|
|
|
|
|
|
## en-US
|
|
|
|
|
2018-05-23 11:13:50 +08:00
|
|
|
Basic drawer.
|
2018-05-23 10:56:37 +08:00
|
|
|
|
2020-05-19 18:11:21 +08:00
|
|
|
```tsx
|
|
|
|
import React, { useState } from 'react';
|
2018-05-23 10:56:37 +08:00
|
|
|
import { Drawer, Button } from 'antd';
|
|
|
|
|
2020-05-19 18:11:21 +08:00
|
|
|
const App: React.FC = () => {
|
|
|
|
const [visible, setVisible] = useState(false);
|
|
|
|
const showDrawer = () => {
|
|
|
|
setVisible(true);
|
2018-05-23 10:56:37 +08:00
|
|
|
};
|
2020-05-19 18:11:21 +08:00
|
|
|
const onClose = () => {
|
|
|
|
setVisible(false);
|
2018-05-23 10:56:37 +08:00
|
|
|
};
|
2020-05-19 18:11:21 +08:00
|
|
|
return (
|
|
|
|
<>
|
|
|
|
<Button type="primary" onClick={showDrawer}>
|
|
|
|
Open
|
|
|
|
</Button>
|
|
|
|
<Drawer
|
|
|
|
title="Basic Drawer"
|
|
|
|
placement="right"
|
|
|
|
closable={false}
|
|
|
|
onClose={onClose}
|
|
|
|
visible={visible}
|
|
|
|
>
|
|
|
|
<p>Some contents...</p>
|
|
|
|
<p>Some contents...</p>
|
|
|
|
<p>Some contents...</p>
|
|
|
|
</Drawer>
|
|
|
|
</>
|
|
|
|
);
|
|
|
|
};
|
2018-05-23 10:56:37 +08:00
|
|
|
|
|
|
|
ReactDOM.render(<App />, mountNode);
|
|
|
|
```
|
2020-03-29 10:39:46 +08:00
|
|
|
|
2020-05-19 18:11:21 +08:00
|
|
|
<style>
|
2020-03-29 10:39:46 +08:00
|
|
|
[data-theme='compact'] .ant-drawer-body p {
|
2020-05-19 18:11:21 +08:00
|
|
|
margin-bottom: 0;
|
2020-03-29 10:39:46 +08:00
|
|
|
}
|
2020-05-19 18:11:21 +08:00
|
|
|
</style>
|