2016-03-31 09:40:55 +08:00
|
|
|
---
|
|
|
|
order: 6
|
2017-02-20 22:02:12 +08:00
|
|
|
title:
|
2016-08-11 11:41:06 +08:00
|
|
|
zh-CN: 国际化
|
|
|
|
en-US: Internationalization
|
2016-03-31 09:40:55 +08:00
|
|
|
---
|
2015-11-24 11:01:36 +08:00
|
|
|
|
2016-08-11 11:41:06 +08:00
|
|
|
## zh-CN
|
|
|
|
|
2015-11-24 11:01:36 +08:00
|
|
|
设置 `okText` 与 `cancelText` 以自定义按钮文字。
|
|
|
|
|
2016-08-11 11:41:06 +08:00
|
|
|
## en-US
|
|
|
|
|
|
|
|
To customize the text of the buttons, you need to set `okText` and `cancelText` props.
|
|
|
|
|
2017-02-13 10:55:53 +08:00
|
|
|
````jsx
|
2015-11-24 11:01:36 +08:00
|
|
|
import { Modal, Button } from 'antd';
|
|
|
|
|
2017-02-20 22:02:12 +08:00
|
|
|
class LocalizedModal extends React.Component {
|
|
|
|
state = { visible: false }
|
2018-06-27 15:55:04 +08:00
|
|
|
|
2017-02-20 22:02:12 +08:00
|
|
|
showModal = () => {
|
2015-11-24 11:01:36 +08:00
|
|
|
this.setState({
|
2016-05-11 09:32:33 +08:00
|
|
|
visible: true,
|
2015-11-24 11:01:36 +08:00
|
|
|
});
|
2017-02-20 22:02:12 +08:00
|
|
|
}
|
2018-06-27 15:55:04 +08:00
|
|
|
|
2017-05-16 10:43:12 +08:00
|
|
|
hideModal = () => {
|
2015-11-24 11:01:36 +08:00
|
|
|
this.setState({
|
2016-05-11 09:32:33 +08:00
|
|
|
visible: false,
|
2015-11-24 11:01:36 +08:00
|
|
|
});
|
2017-02-20 22:02:12 +08:00
|
|
|
}
|
2018-06-27 15:55:04 +08:00
|
|
|
|
2015-11-24 11:01:36 +08:00
|
|
|
render() {
|
2016-01-07 16:29:12 +08:00
|
|
|
return (
|
|
|
|
<div>
|
2017-05-16 10:43:12 +08:00
|
|
|
<Button type="primary" onClick={this.showModal}>Modal</Button>
|
2017-05-15 14:37:22 +08:00
|
|
|
<Modal
|
|
|
|
title="Modal"
|
|
|
|
visible={this.state.visible}
|
2017-05-16 10:43:12 +08:00
|
|
|
onOk={this.hideModal}
|
|
|
|
onCancel={this.hideModal}
|
|
|
|
okText="确认"
|
|
|
|
cancelText="取消"
|
2016-06-06 13:54:10 +08:00
|
|
|
>
|
2016-01-07 16:29:12 +08:00
|
|
|
<p>Bla bla ...</p>
|
|
|
|
<p>Bla bla ...</p>
|
|
|
|
<p>Bla bla ...</p>
|
|
|
|
</Modal>
|
|
|
|
</div>
|
|
|
|
);
|
2017-02-20 22:02:12 +08:00
|
|
|
}
|
|
|
|
}
|
2015-11-24 11:01:36 +08:00
|
|
|
|
|
|
|
function confirm() {
|
|
|
|
Modal.confirm({
|
|
|
|
title: 'Confirm',
|
|
|
|
content: 'Bla bla ...',
|
2017-05-16 10:43:12 +08:00
|
|
|
okText: '确认',
|
|
|
|
cancelText: '取消',
|
2015-11-24 11:01:36 +08:00
|
|
|
});
|
|
|
|
}
|
|
|
|
|
2017-05-16 10:43:12 +08:00
|
|
|
ReactDOM.render(
|
|
|
|
<div>
|
|
|
|
<LocalizedModal />
|
|
|
|
<br />
|
|
|
|
<Button onClick={confirm}>Confirm</Button>
|
|
|
|
</div>,
|
|
|
|
mountNode
|
|
|
|
);
|
2015-11-24 11:01:36 +08:00
|
|
|
````
|