mirror of
https://github.com/ant-design/ant-design.git
synced 2025-01-22 00:43:36 +08:00
58df74c38e
* docs(badge): replace class component with hooks * docs(button): replace class component with hooks * docs(calendar): replace class component with hooks * docs(card): replace class component with hooks * docs(button): replace class component with hooks * chore(deps): remove webpack devDependencies * docs(cascader): replace class component with hooks * docs(checkbox): replace class component with hooks * docs(collapse): replace class component with hooks * docs(comment): replace class component with hooks * docs(descriptions): replace class component with hooks * docs(config-provider): replace class component with hooks * docs(date-picker): replace class component with hooks * docs(drawer): replace class component with hooks * docs(dropdown): replace class component with hooks * docs(dropdown): replace class component with hooks * docs(empty): replace class component with hooks * docs(grid): replace class component with hooks * docs(input): replace class component with hooks * docs(input-number): replace class component with hooks * docs(demo): fix lint error
73 lines
1.3 KiB
Markdown
73 lines
1.3 KiB
Markdown
---
|
|
order: 2
|
|
title:
|
|
zh-CN: 渲染在当前 DOM
|
|
en-US: Render in current dom
|
|
---
|
|
|
|
## zh-CN
|
|
|
|
渲染在当前 dom 里。自定义容器,查看 `getContainer`。
|
|
|
|
## en-US
|
|
|
|
Render in current dom. custom container, check `getContainer`.
|
|
|
|
```jsx
|
|
import { Drawer, Button } from 'antd';
|
|
|
|
export default () => {
|
|
const [visible, setVisible] = React.useState(false);
|
|
|
|
const showDrawer = () => {
|
|
setVisible(true);
|
|
};
|
|
|
|
const onClose = () => {
|
|
setVisible(false);
|
|
};
|
|
|
|
return (
|
|
<div className="site-drawer-render-in-current-wrapper">
|
|
Render in this
|
|
<div style={{ marginTop: 16 }}>
|
|
<Button type="primary" onClick={showDrawer}>
|
|
Open
|
|
</Button>
|
|
</div>
|
|
<Drawer
|
|
title="Basic Drawer"
|
|
placement="right"
|
|
closable={false}
|
|
onClose={onClose}
|
|
visible={visible}
|
|
getContainer={false}
|
|
style={{ position: 'absolute' }}
|
|
>
|
|
<p>Some contents...</p>
|
|
</Drawer>
|
|
</div>
|
|
);
|
|
};
|
|
```
|
|
|
|
```css
|
|
.site-drawer-render-in-current-wrapper {
|
|
position: relative;
|
|
height: 200px;
|
|
padding: 48px;
|
|
overflow: hidden;
|
|
text-align: center;
|
|
background: #fafafa;
|
|
border: 1px solid #ebedf0;
|
|
border-radius: 2px;
|
|
}
|
|
```
|
|
|
|
<style>
|
|
[data-theme="dark"] .site-drawer-render-in-current-wrapper {
|
|
background: #000;
|
|
border: 1px solid #303030;
|
|
}
|
|
</style>
|