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 = () => {
|
2022-08-23 16:55:57 +08:00
|
|
|
const [open, setOpen] = useState(false);
|
2022-05-19 09:46:26 +08:00
|
|
|
|
2020-09-03 16:29:40 +08:00
|
|
|
return (
|
|
|
|
<>
|
2022-08-23 16:55:57 +08:00
|
|
|
<Button type="primary" onClick={() => setOpen(true)}>
|
2020-09-03 16:29:40 +08:00
|
|
|
Open Modal of 1000px width
|
|
|
|
</Button>
|
|
|
|
<Modal
|
|
|
|
title="Modal 1000px width"
|
|
|
|
centered
|
2022-08-23 16:55:57 +08:00
|
|
|
open={open}
|
|
|
|
onOk={() => setOpen(false)}
|
|
|
|
onCancel={() => setOpen(false)}
|
2020-09-03 16:29:40 +08:00
|
|
|
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
|
|
|
```
|