Antd 允许在 Modal 中嵌套另一个 Modal。为了实现在一个 Modal 中弹出确认提示,可以在外部 Modal 的 cancel 和 ok 按钮上添加对内部 Modal 的操作。以下是代码示例:
import React, { useState } from 'react';
import { Modal, Button } from 'antd';
const NestedModal = () => {
const [visible, setVisible] = useState(false);
const showModal = () => {
setVisible(true);
};
const handleOk = () => {
console.log('Clicked OK');
setVisible(false);
};
const handleCancel = () => {
console.log('Clicked cancel');
setVisible(false);
};
return (
<>
This is the nested modal content.
>
);
};
const App = () => {
const [visible, setVisible] = useState(false);
const showModal = () => {
setVisible(true);
};
const handleOk = () => {
console.log('Clicked OK');
setVisible(false);
};
const handleCancel = () => {
console.log('Clicked cancel');
setVisible(false);
};
return (
<>
This is the outer modal content.
>
);
};
export default App;