You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

48 lines
838 B

10 years ago
# 基本
- order: 0
第一个对话框。
10 years ago
---
````jsx
10 years ago
var Modal = antd.Modal;
10 years ago
10 years ago
var Test = React.createClass({
10 years ago
getInitialState(){
return{
10 years ago
visible: false
10 years ago
}
},
showModal() {
10 years ago
this.setState({
10 years ago
visible: true
10 years ago
});
10 years ago
},
handleOk() {
console.log('点击了确定');
10 years ago
this.setState({
10 years ago
visible: false
10 years ago
});
10 years ago
},
handleCancel() {
console.log('点击了取消');
10 years ago
},
render() {
10 years ago
return <div>
<button className="ant-btn ant-btn-primary" onClick={this.showModal}>显示对话框</button>
<Modal title="第一个 Modal"
10 years ago
visible={this.state.visible}
onOk={this.handleOk}
onCancel={this.handleCancel}>
<p>对话框的内容</p>
</Modal>
10 years ago
</div>;
}
});
10 years ago
10 years ago
React.render(<Test/> , document.getElementById('components-modal-demo-basic'));
10 years ago
````