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.
|
|
|
|
|
2022-05-19 09:46:26 +08:00
|
|
|
```tsx
|
|
|
|
import React, { useState } from 'react';
|
2020-07-21 12:26:56 +08:00
|
|
|
import { Modal, Button, Space } from 'antd';
|
2019-12-25 21:28:06 +08:00
|
|
|
import { ExclamationCircleOutlined } from '@ant-design/icons';
|
2015-11-24 11:01:36 +08:00
|
|
|
|
2022-05-18 19:29:01 +08:00
|
|
|
const LocalizedModal = () => {
|
2022-05-19 09:46:26 +08:00
|
|
|
const [visible, setVisible] = useState(false);
|
2018-06-27 15:55:04 +08:00
|
|
|
|
2022-05-18 19:29:01 +08:00
|
|
|
const showModal = () => {
|
|
|
|
setVisible(true);
|
2019-05-07 14:57:32 +08:00
|
|
|
};
|
2018-06-27 15:55:04 +08:00
|
|
|
|
2022-05-18 19:29:01 +08:00
|
|
|
const hideModal = () => {
|
|
|
|
setVisible(false);
|
2019-05-07 14:57:32 +08:00
|
|
|
};
|
2018-06-27 15:55:04 +08:00
|
|
|
|
2022-05-18 19:29:01 +08:00
|
|
|
return (
|
|
|
|
<>
|
|
|
|
<Button type="primary" onClick={showModal}>
|
|
|
|
Modal
|
|
|
|
</Button>
|
|
|
|
<Modal
|
|
|
|
title="Modal"
|
|
|
|
visible={visible}
|
|
|
|
onOk={hideModal}
|
|
|
|
onCancel={hideModal}
|
|
|
|
okText="确认"
|
|
|
|
cancelText="取消"
|
|
|
|
>
|
|
|
|
<p>Bla bla ...</p>
|
|
|
|
<p>Bla bla ...</p>
|
|
|
|
<p>Bla bla ...</p>
|
|
|
|
</Modal>
|
|
|
|
</>
|
|
|
|
);
|
|
|
|
};
|
2015-11-24 11:01:36 +08:00
|
|
|
|
2022-05-19 09:46:26 +08:00
|
|
|
const confirm = () => {
|
2015-11-24 11:01:36 +08:00
|
|
|
Modal.confirm({
|
|
|
|
title: 'Confirm',
|
2019-12-25 21:28:06 +08:00
|
|
|
icon: <ExclamationCircleOutlined />,
|
2015-11-24 11:01:36 +08:00
|
|
|
content: 'Bla bla ...',
|
2017-05-16 10:43:12 +08:00
|
|
|
okText: '确认',
|
|
|
|
cancelText: '取消',
|
2015-11-24 11:01:36 +08:00
|
|
|
});
|
2022-05-19 09:46:26 +08:00
|
|
|
};
|
2015-11-24 11:01:36 +08:00
|
|
|
|
2022-05-19 09:46:26 +08:00
|
|
|
const App: React.FC = () => (
|
2020-07-21 12:26:56 +08:00
|
|
|
<Space>
|
2017-05-16 10:43:12 +08:00
|
|
|
<LocalizedModal />
|
|
|
|
<Button onClick={confirm}>Confirm</Button>
|
2022-04-03 23:27:45 +08:00
|
|
|
</Space>
|
2017-05-16 10:43:12 +08:00
|
|
|
);
|
2022-05-19 09:46:26 +08:00
|
|
|
|
|
|
|
export default App;
|
2019-05-07 14:57:32 +08:00
|
|
|
```
|