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

39 lines
717 B
Markdown
Raw Normal View History

2015-06-04 21:17:52 +08:00
# 基本
- order: 0
2015-06-12 17:11:32 +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({
2015-06-12 17:11:32 +08:00
showModal() {
this.refs.modal.show();
2015-06-10 22:02:13 +08:00
},
2015-06-12 17:11:32 +08:00
handleOk() {
console.log('点击了确定');
this.refs.modal.hide();
2015-06-10 22:02:13 +08:00
},
2015-06-12 17:11:32 +08:00
handleCancel() {
console.log('点击了取消');
2015-06-10 22:02:13 +08:00
},
2015-06-12 17:11:32 +08:00
render() {
2015-06-10 22:02:13 +08:00
return <div>
2015-06-12 17:11:32 +08:00
<button className="ant-btn ant-btn-primary" onClick={this.showModal}>显示对话框</button>
<Modal title="第一个 Modal"
ref="modal"
onOk={this.handleOk}
onCancel={this.handleCancel}>
<p>对话框的内容</p>
</Modal>
2015-06-10 22:02:13 +08:00
</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
````
2015-06-12 17:11:32 +08:00