ant-design/components/modal/demo/basic.md

71 lines
1.0 KiB
Markdown
Raw Normal View History

2016-03-31 09:40:55 +08:00
---
order: 0
2016-09-14 14:49:12 +08:00
title:
2016-08-11 11:41:06 +08:00
zh-CN: 基本
en-US: Basic
2016-03-31 09:40:55 +08:00
---
2015-06-04 21:17:52 +08:00
2016-09-14 14:49:12 +08:00
## zh-CN
2016-08-11 11:41:06 +08:00
2015-06-12 17:44:29 +08:00
第一个对话框。
2015-06-04 21:17:52 +08:00
2016-09-14 14:49:12 +08:00
## en-US
2016-08-11 11:41:06 +08:00
Basic modal.
2016-08-11 11:41:06 +08:00
2017-02-13 10:55:53 +08:00
````jsx
import { Modal, Button } from 'antd';
2015-06-04 21:17:52 +08:00
class App extends React.Component {
state = { visible: false }
2018-06-27 15:55:04 +08:00
showModal = () => {
2015-06-12 23:31:44 +08:00
this.setState({
2016-05-11 09:32:33 +08:00
visible: true,
2015-06-12 23:31:44 +08:00
});
}
2018-06-27 15:55:04 +08:00
handleOk = (e) => {
console.log(e);
2015-06-12 23:31:44 +08:00
this.setState({
2016-05-11 09:32:33 +08:00
visible: false,
2015-06-12 23:31:44 +08:00
});
}
2018-06-27 15:55:04 +08:00
handleCancel = (e) => {
2016-02-02 14:54:34 +08:00
console.log(e);
2015-09-08 12:38:21 +08:00
this.setState({
2016-05-11 09:32:33 +08:00
visible: false,
2015-09-08 12:38:21 +08:00
});
}
2018-06-27 15:55:04 +08:00
2015-06-12 17:11:32 +08:00
render() {
return (
<div>
2018-08-25 22:04:15 +08:00
<Button type="primary" onClick={this.showModal}>
Open Modal
</Button>
2017-05-15 14:37:22 +08:00
<Modal
title="Basic Modal"
visible={this.state.visible}
onOk={this.handleOk}
onCancel={this.handleCancel}
>
<p>Some contents...</p>
<p>Some contents...</p>
<p>Some contents...</p>
</Modal>
</div>
);
}
}
2015-06-04 21:17:52 +08:00
ReactDOM.render(<App />, mountNode);
2015-06-04 21:17:52 +08:00
````
<style>
.ant-modal p {
margin: 0;
}
</style>