You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
66 lines
1.4 KiB
TypeScript
66 lines
1.4 KiB
TypeScript
1 year ago
|
import React, { useState } from 'react';
|
||
|
import { Button, Modal, Space } from 'antd';
|
||
|
|
||
|
const App: React.FC = () => {
|
||
|
const [open, setOpen] = useState(false);
|
||
|
|
||
|
const showModal = () => {
|
||
|
setOpen(true);
|
||
|
};
|
||
|
const handleOk = () => {
|
||
|
setOpen(false);
|
||
|
};
|
||
|
|
||
|
const handleCancel = () => {
|
||
|
setOpen(false);
|
||
|
};
|
||
|
return (
|
||
|
<>
|
||
|
<Space>
|
||
|
<Button type="primary" onClick={showModal}>
|
||
|
Open Modal
|
||
|
</Button>
|
||
|
<Button
|
||
|
type="primary"
|
||
|
onClick={() => {
|
||
|
Modal.confirm({
|
||
|
title: 'Confirm',
|
||
|
content: 'Bla bla ...',
|
||
|
footer: (_, { OkBtn, CancelBtn }) => (
|
||
|
<>
|
||
|
<Button>Custom Button</Button>
|
||
|
<CancelBtn />
|
||
|
<OkBtn />
|
||
|
</>
|
||
|
),
|
||
|
});
|
||
|
}}
|
||
|
>
|
||
|
Open Modal Confirm
|
||
|
</Button>
|
||
|
</Space>
|
||
|
<Modal
|
||
|
open={open}
|
||
|
title="Title"
|
||
|
onOk={handleOk}
|
||
|
onCancel={handleCancel}
|
||
|
footer={(_, { OkBtn, CancelBtn }) => (
|
||
|
<>
|
||
|
<Button>Custom Button</Button>
|
||
|
<CancelBtn />
|
||
|
<OkBtn />
|
||
|
</>
|
||
|
)}
|
||
|
>
|
||
|
<p>Some contents...</p>
|
||
|
<p>Some contents...</p>
|
||
|
<p>Some contents...</p>
|
||
|
<p>Some contents...</p>
|
||
|
<p>Some contents...</p>
|
||
|
</Modal>
|
||
|
</>
|
||
|
);
|
||
|
};
|
||
|
|
||
|
export default App;
|