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

69 lines
1.2 KiB
Markdown
Raw Normal View History

2018-05-23 10:56:37 +08:00
---
2018-06-28 16:17:22 +08:00
order: 1
2018-05-23 10:56:37 +08:00
title:
2018-06-28 16:17:22 +08:00
zh-CN: 左侧滑出
en-US: Left Silder
2018-05-23 10:56:37 +08:00
---
## zh-CN
2018-06-28 16:17:22 +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-06-28 16:17:22 +08:00
placement="left"
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);
```