mirror of
https://github.com/ant-design/ant-design.git
synced 2024-12-04 17:09:46 +08:00
6776bb8916
* docs: update demo * chore: add script * test: fix demo test * docs: convert demos * chore: move script * test: remove react-dom import * chore: update deps * docs: update riddle js * test: fix image test * docs: fix riddle demo
75 lines
1.3 KiB
Markdown
75 lines
1.3 KiB
Markdown
---
|
|
order: 6
|
|
title:
|
|
zh-CN: 国际化
|
|
en-US: Internationalization
|
|
---
|
|
|
|
## zh-CN
|
|
|
|
设置 `okText` 与 `cancelText` 以自定义按钮文字。
|
|
|
|
## en-US
|
|
|
|
To customize the text of the buttons, you need to set `okText` and `cancelText` props.
|
|
|
|
```jsx
|
|
import { Modal, Button, Space } from 'antd';
|
|
import { ExclamationCircleOutlined } from '@ant-design/icons';
|
|
|
|
class LocalizedModal extends React.Component {
|
|
state = { visible: false };
|
|
|
|
showModal = () => {
|
|
this.setState({
|
|
visible: true,
|
|
});
|
|
};
|
|
|
|
hideModal = () => {
|
|
this.setState({
|
|
visible: false,
|
|
});
|
|
};
|
|
|
|
render() {
|
|
return (
|
|
<>
|
|
<Button type="primary" onClick={this.showModal}>
|
|
Modal
|
|
</Button>
|
|
<Modal
|
|
title="Modal"
|
|
visible={this.state.visible}
|
|
onOk={this.hideModal}
|
|
onCancel={this.hideModal}
|
|
okText="确认"
|
|
cancelText="取消"
|
|
>
|
|
<p>Bla bla ...</p>
|
|
<p>Bla bla ...</p>
|
|
<p>Bla bla ...</p>
|
|
</Modal>
|
|
</>
|
|
);
|
|
}
|
|
}
|
|
|
|
function confirm() {
|
|
Modal.confirm({
|
|
title: 'Confirm',
|
|
icon: <ExclamationCircleOutlined />,
|
|
content: 'Bla bla ...',
|
|
okText: '确认',
|
|
cancelText: '取消',
|
|
});
|
|
}
|
|
|
|
export default () => (
|
|
<Space>
|
|
<LocalizedModal />
|
|
<Button onClick={confirm}>Confirm</Button>
|
|
</Space>
|
|
);
|
|
```
|