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
|
|
|
|
|
2021-06-11 08:39:17 +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
|
2022-05-23 14:37:16 +08:00
|
|
|
import { Button, Drawer } from 'antd';
|
2020-05-19 18:11:21 +08:00
|
|
|
import React, { useState } from 'react';
|
2018-05-23 10:56:37 +08:00
|
|
|
|
2020-05-19 18:11:21 +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
|
|
|
|
2020-05-19 18:11:21 +08:00
|
|
|
const showDrawer = () => {
|
2022-08-23 14:52:37 +08:00
|
|
|
setOpen(true);
|
2018-05-23 10:56:37 +08:00
|
|
|
};
|
2022-05-19 09:46:26 +08:00
|
|
|
|
2020-05-19 18:11:21 +08:00
|
|
|
const onClose = () => {
|
2022-08-23 14:52:37 +08:00
|
|
|
setOpen(false);
|
2018-05-23 10:56:37 +08:00
|
|
|
};
|
2022-05-19 09:46:26 +08:00
|
|
|
|
2020-05-19 18:11:21 +08:00
|
|
|
return (
|
|
|
|
<>
|
|
|
|
<Button type="primary" onClick={showDrawer}>
|
|
|
|
Open
|
|
|
|
</Button>
|
2022-08-23 14:52:37 +08:00
|
|
|
<Drawer title="Basic Drawer" placement="right" onClose={onClose} open={open}>
|
2020-05-19 18:11:21 +08:00
|
|
|
<p>Some contents...</p>
|
|
|
|
<p>Some contents...</p>
|
|
|
|
<p>Some contents...</p>
|
|
|
|
</Drawer>
|
|
|
|
</>
|
|
|
|
);
|
|
|
|
};
|
2018-05-23 10:56:37 +08:00
|
|
|
|
2022-04-15 16:20:56 +08:00
|
|
|
export default App;
|
2018-05-23 10:56:37 +08:00
|
|
|
```
|
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>
|