2015-06-04 21:17:52 +08:00
|
|
|
# 基本
|
|
|
|
|
|
|
|
- order: 0
|
|
|
|
|
2015-06-10 16:43:35 +08:00
|
|
|
使用很简单。
|
2015-06-04 21:17:52 +08:00
|
|
|
|
|
|
|
---
|
|
|
|
|
|
|
|
````jsx
|
2015-06-10 22:02:13 +08:00
|
|
|
var Modal = antd.Modal;
|
2015-06-04 21:17:52 +08:00
|
|
|
|
2015-06-10 22:02:13 +08:00
|
|
|
var Test = React.createClass({
|
|
|
|
getInitialState(){
|
|
|
|
return {
|
|
|
|
visible:false
|
|
|
|
};
|
|
|
|
},
|
|
|
|
showModal(){
|
|
|
|
this.setState({
|
|
|
|
visible:true
|
|
|
|
});
|
|
|
|
},
|
|
|
|
handleOk(){
|
|
|
|
alert('ok');
|
|
|
|
var self = this;
|
|
|
|
setTimeout(function(){
|
|
|
|
self.setState({
|
|
|
|
visible:false
|
|
|
|
});
|
|
|
|
},200);
|
|
|
|
},
|
|
|
|
handleCancel(){
|
|
|
|
var self = this;
|
|
|
|
alert('cancel');
|
|
|
|
setTimeout(function(){
|
|
|
|
self.setState({
|
|
|
|
visible:false
|
|
|
|
});
|
|
|
|
},200);
|
|
|
|
},
|
|
|
|
render(){
|
|
|
|
return <div>
|
|
|
|
<button className="ant-btn ant-btn-primary" onClick={this.showModal}>显示对话框</button>
|
|
|
|
<Modal title="第一个 Modal" visible={this.state.visible} onOk={this.handleOk} onBeforeClose={this.handleCancel}><p>对话框的内容</p></Modal>
|
|
|
|
</div>;
|
|
|
|
}
|
|
|
|
});
|
2015-06-04 21:17:52 +08:00
|
|
|
|
2015-06-10 22:02:13 +08:00
|
|
|
React.render(<Test/> , document.getElementById('components-modal-demo-basic'));
|
2015-06-04 21:17:52 +08:00
|
|
|
````
|