2016-03-31 09:40:55 +08:00
|
|
|
---
|
|
|
|
order: 6
|
|
|
|
title: 国际化
|
|
|
|
---
|
2015-11-24 11:01:36 +08:00
|
|
|
|
|
|
|
设置 `okText` 与 `cancelText` 以自定义按钮文字。
|
|
|
|
|
|
|
|
````jsx
|
|
|
|
import { Modal, Button } from 'antd';
|
|
|
|
|
|
|
|
const LocalizedModal = React.createClass({
|
|
|
|
getInitialState() {
|
|
|
|
return { visible: false };
|
|
|
|
},
|
|
|
|
showModal() {
|
|
|
|
this.setState({
|
|
|
|
visible: true
|
|
|
|
});
|
|
|
|
},
|
|
|
|
handleOk() {
|
|
|
|
this.setState({
|
|
|
|
visible: false
|
|
|
|
});
|
|
|
|
},
|
|
|
|
handleCancel() {
|
|
|
|
this.setState({
|
|
|
|
visible: false
|
|
|
|
});
|
|
|
|
},
|
|
|
|
render() {
|
2016-01-07 16:29:12 +08:00
|
|
|
return (
|
|
|
|
<div>
|
|
|
|
<Button type="primary" onClick={this.showModal}>Show Modal</Button>
|
|
|
|
<Modal title="Modal" visible={this.state.visible}
|
2016-01-08 14:41:05 +08:00
|
|
|
onOk={this.handleOk} onCancel={this.handleCancel}
|
|
|
|
okText="OK" cancelText="Cancel">
|
2016-01-07 16:29:12 +08:00
|
|
|
<p>Bla bla ...</p>
|
|
|
|
<p>Bla bla ...</p>
|
|
|
|
<p>Bla bla ...</p>
|
|
|
|
</Modal>
|
|
|
|
</div>
|
|
|
|
);
|
2015-11-24 11:01:36 +08:00
|
|
|
}
|
|
|
|
});
|
|
|
|
|
|
|
|
function confirm() {
|
|
|
|
Modal.confirm({
|
|
|
|
title: 'Confirm',
|
|
|
|
content: 'Bla bla ...',
|
|
|
|
okText: 'OK',
|
|
|
|
cancelText: 'Cancel'
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
ReactDOM.render(<div>
|
|
|
|
<LocalizedModal />
|
|
|
|
<br />
|
|
|
|
<Button onClick={confirm}>confirm</Button>
|
2015-12-29 12:08:58 +08:00
|
|
|
</div>, mountNode);
|
2015-11-24 11:01:36 +08:00
|
|
|
````
|
|
|
|
|