ant-design/components/drawer/demo/basic-right.md

69 lines
1.2 KiB
Markdown
Raw Normal View History

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
```jsx
import { Drawer, Button } from 'antd';
class App extends React.Component {
state = { visible: false };
2018-06-28 16:17:22 +08:00
toogerHotjar = () => {
const hotjar = document.getElementById('_hj_feedback_container');
if (hotjar.style.display === 'none') {
hotjar.style.display = '';
} else {
hotjar.style.display = 'none';
}
};
2018-05-23 10:56:37 +08:00
showDrawer = () => {
2018-06-28 16:17:22 +08:00
this.toogerHotjar();
2018-05-23 10:56:37 +08:00
this.setState({
visible: true,
});
};
onClose = () => {
2018-06-28 16:17:22 +08:00
this.setState(
{
visible: false,
},
() => {
this.toogerHotjar();
}
);
2018-05-23 10:56:37 +08:00
};
render() {
return (
<div>
<Button type="primary" onClick={this.showDrawer}>
Open
</Button>
<Drawer
title="Basic Drawer"
2018-05-27 00:00:07 +08:00
placement="right"
2018-06-22 15:46:21 +08:00
closable={false}
2018-05-23 10:56:37 +08:00
onClose={this.onClose}
visible={this.state.visible}
>
<p>Some contents...</p>
<p>Some contents...</p>
<p>Some contents...</p>
</Drawer>
</div>
);
}
}
ReactDOM.render(<App />, mountNode);
```