2020-09-03 16:29:40 +08:00
|
|
|
---
|
|
|
|
order: 13
|
|
|
|
title:
|
|
|
|
zh-CN: 自定义模态的宽度
|
|
|
|
en-US: To customize the width of modal
|
|
|
|
---
|
|
|
|
|
|
|
|
## zh-CN
|
|
|
|
|
|
|
|
使用 `width` 来设置模态对话框的宽度。
|
|
|
|
|
|
|
|
## en-US
|
|
|
|
|
|
|
|
Use `width` to set the width of the modal dialog.
|
|
|
|
|
2022-05-19 09:46:26 +08:00
|
|
|
```tsx
|
2022-05-23 14:37:16 +08:00
|
|
|
import { Button, Modal } from 'antd';
|
2020-09-03 16:29:40 +08:00
|
|
|
import React, { useState } from 'react';
|
|
|
|
|
2022-05-19 09:46:26 +08:00
|
|
|
const App: React.FC = () => {
|
2020-09-03 16:29:40 +08:00
|
|
|
const [visible, setVisible] = useState(false);
|
2022-05-19 09:46:26 +08:00
|
|
|
|
2020-09-03 16:29:40 +08:00
|
|
|
return (
|
|
|
|
<>
|
|
|
|
<Button type="primary" onClick={() => setVisible(true)}>
|
|
|
|
Open Modal of 1000px width
|
|
|
|
</Button>
|
|
|
|
<Modal
|
|
|
|
title="Modal 1000px width"
|
|
|
|
centered
|
|
|
|
visible={visible}
|
|
|
|
onOk={() => setVisible(false)}
|
|
|
|
onCancel={() => setVisible(false)}
|
|
|
|
width={1000}
|
|
|
|
>
|
|
|
|
<p>some contents...</p>
|
|
|
|
<p>some contents...</p>
|
|
|
|
<p>some contents...</p>
|
|
|
|
</Modal>
|
|
|
|
</>
|
|
|
|
);
|
2020-10-21 11:06:07 +08:00
|
|
|
};
|
2020-09-03 16:29:40 +08:00
|
|
|
|
2022-04-15 16:20:56 +08:00
|
|
|
export default App;
|
2020-09-03 16:29:40 +08:00
|
|
|
```
|