2015-06-12 17:37:39 +08:00
|
|
|
# 自定义页脚
|
|
|
|
|
|
|
|
- order: 2
|
|
|
|
|
2015-06-12 17:44:29 +08:00
|
|
|
更复杂的例子,自定义了页脚的按钮,点击提交后进入 loading 状态,完成后关闭。
|
2015-06-12 17:37:39 +08:00
|
|
|
|
|
|
|
---
|
|
|
|
|
|
|
|
````jsx
|
|
|
|
var Modal = antd.Modal;
|
2015-10-08 15:13:04 +08:00
|
|
|
var Button = antd.Button;
|
2015-06-12 17:37:39 +08:00
|
|
|
|
|
|
|
var Test = React.createClass({
|
|
|
|
getInitialState: function() {
|
|
|
|
return {
|
2015-06-12 23:31:44 +08:00
|
|
|
loading: false,
|
2015-06-14 13:20:35 +08:00
|
|
|
visible: false
|
2015-06-12 17:37:39 +08:00
|
|
|
};
|
|
|
|
},
|
2015-08-18 12:26:19 +08:00
|
|
|
showModal() {
|
2015-08-18 11:46:07 +08:00
|
|
|
this.setState({
|
2015-08-18 12:26:19 +08:00
|
|
|
visible: true
|
2015-08-18 11:46:07 +08:00
|
|
|
});
|
2015-06-12 17:37:39 +08:00
|
|
|
},
|
|
|
|
handleOk() {
|
2015-06-12 17:44:29 +08:00
|
|
|
this.setState({ loading: true });
|
2015-08-18 11:46:07 +08:00
|
|
|
setTimeout(() => {
|
2015-06-15 21:30:17 +08:00
|
|
|
this.setState({ loading: false, visible: false });
|
2015-06-12 17:37:39 +08:00
|
|
|
}, 3000);
|
|
|
|
},
|
|
|
|
handleCancel() {
|
2015-06-15 21:30:17 +08:00
|
|
|
this.setState({ visible: false });
|
2015-06-12 17:37:39 +08:00
|
|
|
},
|
|
|
|
render() {
|
|
|
|
return <div>
|
2015-10-08 15:13:04 +08:00
|
|
|
<Button type="primary" onClick={this.showModal}>
|
2015-06-12 17:37:39 +08:00
|
|
|
显示对话框
|
2015-10-08 15:13:04 +08:00
|
|
|
</Button>
|
2015-06-12 23:31:44 +08:00
|
|
|
<Modal ref="modal"
|
|
|
|
visible={this.state.visible}
|
|
|
|
title="对话框标题" onOk={this.handleOk} onCancel={this.handleCancel}
|
2015-06-12 17:37:39 +08:00
|
|
|
footer={[
|
2015-10-26 11:02:48 +08:00
|
|
|
<Button key="back" size="large" onClick={this.handleCancel}>返 回</Button>,
|
|
|
|
<Button key="submit" type="primary" size="large" loading={this.state.loading} onClick={this.handleOk}>
|
2015-06-12 17:44:29 +08:00
|
|
|
提 交
|
2015-10-08 15:13:04 +08:00
|
|
|
</Button>
|
2015-06-12 17:37:39 +08:00
|
|
|
]}>
|
|
|
|
<p>对话框的内容</p>
|
2015-06-15 21:30:17 +08:00
|
|
|
<p>对话框的内容</p>
|
|
|
|
<p>对话框的内容</p>
|
|
|
|
<p>对话框的内容</p>
|
|
|
|
<p>对话框的内容</p>
|
2015-06-12 17:37:39 +08:00
|
|
|
</Modal>
|
|
|
|
</div>;
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|
2015-10-20 16:47:55 +08:00
|
|
|
ReactDOM.render(<Test/> , document.getElementById('components-modal-demo-footer'));
|
2015-06-12 17:37:39 +08:00
|
|
|
````
|