我正在尝试将antd用于我的 React 应用程序,但提供的模式似乎不起作用。该按钮是可见的,但是当我单击它时没有任何反应,也没有抛出错误。
我还尝试了官方模态文档中提供的其他模态。
模态代码:
import { Button, Modal } from 'antd';
import React, { useState } from 'react';
const App = () => {
const [isModalOpen, setIsModalOpen] = useState(false);
const showModal = () => {
setIsModalOpen(true);
};
const handleOk = () => {
setIsModalOpen(false);
};
const handleCancel = () => {
setIsModalOpen(false);
};
return (
<>
<Button type="primary" onClick={showModal}>
Open Modal
</Button>
<Modal title="Basic Modal" open={isModalOpen} onOk={handleOk} onCancel={handleCancel}>
<p>Some contents...</p>
<p>Some contents...</p>
<p>Some contents...</p>
</Modal> …Run Code Online (Sandbox Code Playgroud)