下面给出一个可能的解决方法,假设您的模态框名称为"modal",且您的组件名称为"YourComponent":
import { Modal } from 'antd'; import 'antd/dist/antd.css';
import React, { useState } from 'react';
const YourComponent = () => { const [visible, setVisible] = useState(false);
const showModal = () => { setVisible(true); };
const handleOk = () => { setVisible(false); };
const handleCancel = () => { setVisible(false); };
return (
<>
一些内容...
export default YourComponent;
如果问题仍然存在,请尝试更新Antd的版本或升级您的React和/或Next.js版本。
上一篇:Antd模态框头部能否添加按钮?