ant design的modal怎样去掉取消按钮
时间: 2023-08-02 13:10:28 浏览: 120
可以通过设置 `footer` 属性来去掉 Modal 的取消按钮。将 `footer` 设置为 `null` 或者设置 `cancelButtonProps` 属性的 `visible` 属性为 `false` 都可以去掉取消按钮。
示例代码如下:
```jsx
import { Modal } from 'antd';
function MyModal() {
const handleOk = () => {
// 确认操作
};
return (
<Modal
title="Basic Modal"
visible={true}
onOk={handleOk}
footer={null} // 去掉取消按钮
>
<p>Some contents...</p>
</Modal>
);
}
```
或者:
```jsx
import { Modal } from 'antd';
function MyModal() {
const handleOk = () => {
// 确认操作
};
return (
<Modal
title="Basic Modal"
visible={true}
onOk={handleOk}
cancelButtonProps={{ visible: false }} // 去掉取消按钮
>
<p>Some contents...</p>
</Modal>
);
}
```