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

73 lines
1.7 KiB
Markdown
Raw Normal View History

2016-03-31 09:40:55 +08:00
---
order: 2
2016-08-23 21:00:35 +08:00
title:
2016-08-11 11:41:06 +08:00
zh-CN: 自定义页脚
en-US: Customized footer
2016-03-31 09:40:55 +08:00
---
2015-06-12 17:37:39 +08:00
2016-08-11 11:41:06 +08:00
## zh-CN
2015-06-12 17:44:29 +08:00
更复杂的例子,自定义了页脚的按钮,点击提交后进入 loading 状态,完成后关闭。
2015-06-12 17:37:39 +08:00
2016-08-11 11:41:06 +08:00
## en-US
A more complex example, as illustrated in this example, we define a customized footer button bar,
the dialog will change to loading state after clicking submit button , when the loading is over,
the modal dialog will be closed.
2015-06-12 17:37:39 +08:00
````jsx
import { Modal, Button } from 'antd';
2015-06-12 17:37:39 +08:00
const Test = React.createClass({
getInitialState() {
2015-06-12 17:37:39 +08:00
return {
2015-06-12 23:31:44 +08:00
loading: false,
2016-05-11 09:32:33 +08:00
visible: false,
2015-06-12 17:37:39 +08:00
};
},
showModal() {
this.setState({
2016-05-11 09:32:33 +08:00
visible: true,
});
2015-06-12 17:37:39 +08:00
},
handleOk() {
2015-06-12 17:44:29 +08:00
this.setState({ loading: true });
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>
<Button type="primary" onClick={this.showModal}>
2016-08-11 11:41:06 +08:00
Open modal dialog
</Button>
2016-08-23 21:00:35 +08:00
<Modal
visible={this.state.visible}
2016-08-23 21:00:35 +08:00
title="Title"
onOk={this.handleOk}
onCancel={this.handleCancel}
footer={[
2016-08-11 11:41:06 +08:00
<Button key="back" type="ghost" size="large" onClick={this.handleCancel}>Return</Button>,
<Button key="submit" type="primary" size="large" loading={this.state.loading} onClick={this.handleOk}>
2016-08-11 11:41:06 +08:00
Submit
2016-05-11 09:32:33 +08:00
</Button>,
]}
>
2016-08-11 11:41:06 +08:00
<p>Some contents...</p>
<p>Some contents...</p>
<p>Some contents...</p>
<p>Some contents...</p>
<p>Some contents...</p>
</Modal>
</div>
);
2016-05-11 09:32:33 +08:00
},
2015-06-12 17:37:39 +08:00
});
ReactDOM.render(<Test />, mountNode);
2015-06-12 17:37:39 +08:00
````