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

76 lines
1.3 KiB
Markdown
Raw Normal View History

2016-03-31 09:40:55 +08:00
---
order: 6
title:
2016-08-11 11:41:06 +08:00
zh-CN: 国际化
en-US: Internationalization
2016-03-31 09:40:55 +08:00
---
2016-08-11 11:41:06 +08:00
## zh-CN
设置 `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.
2019-05-07 14:57:32 +08:00
```jsx
import { Modal, Button, Space } from 'antd';
2019-12-25 21:28:06 +08:00
import { ExclamationCircleOutlined } from '@ant-design/icons';
class LocalizedModal extends React.Component {
2019-05-07 14:57:32 +08:00
state = { visible: false };
2018-06-27 15:55:04 +08:00
showModal = () => {
this.setState({
2016-05-11 09:32:33 +08:00
visible: true,
});
2019-05-07 14:57:32 +08:00
};
2018-06-27 15:55:04 +08:00
hideModal = () => {
this.setState({
2016-05-11 09:32:33 +08:00
visible: false,
});
2019-05-07 14:57:32 +08:00
};
2018-06-27 15:55:04 +08:00
render() {
return (
2020-07-16 13:46:57 +08:00
<>
2019-05-07 14:57:32 +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}
onOk={this.hideModal}
onCancel={this.hideModal}
okText="确认"
cancelText="取消"
>
<p>Bla bla ...</p>
<p>Bla bla ...</p>
<p>Bla bla ...</p>
</Modal>
2020-07-16 13:46:57 +08:00
</>
);
}
}
function confirm() {
Modal.confirm({
title: 'Confirm',
2019-12-25 21:28:06 +08:00
icon: <ExclamationCircleOutlined />,
content: 'Bla bla ...',
okText: '确认',
cancelText: '取消',
});
}
ReactDOM.render(
<Space>
<LocalizedModal />
<Button onClick={confirm}>Confirm</Button>
</Space>,
2019-05-07 14:57:32 +08:00
mountNode,
);
2019-05-07 14:57:32 +08:00
```