mirror of
https://gitee.com/ant-design/ant-design.git
synced 2024-12-04 13:08:41 +08:00
63 lines
1.4 KiB
TypeScript
63 lines
1.4 KiB
TypeScript
|
import React, { useState } from 'react';
|
||
|
import { Button, Modal } from 'antd';
|
||
|
|
||
|
const App: React.FC = () => {
|
||
|
const [loading, setLoading] = useState(false);
|
||
|
const [open, setOpen] = useState(false);
|
||
|
|
||
|
const showModal = () => {
|
||
|
setOpen(true);
|
||
|
};
|
||
|
|
||
|
const handleOk = () => {
|
||
|
setLoading(true);
|
||
|
setTimeout(() => {
|
||
|
setLoading(false);
|
||
|
setOpen(false);
|
||
|
}, 3000);
|
||
|
};
|
||
|
|
||
|
const handleCancel = () => {
|
||
|
setOpen(false);
|
||
|
};
|
||
|
|
||
|
return (
|
||
|
<>
|
||
|
<Button type="primary" onClick={showModal}>
|
||
|
Open Modal with customized footer
|
||
|
</Button>
|
||
|
<Modal
|
||
|
open={open}
|
||
|
title="Title"
|
||
|
onOk={handleOk}
|
||
|
onCancel={handleCancel}
|
||
|
footer={[
|
||
|
<Button key="back" onClick={handleCancel}>
|
||
|
Return
|
||
|
</Button>,
|
||
|
<Button key="submit" type="primary" loading={loading} onClick={handleOk}>
|
||
|
Submit
|
||
|
</Button>,
|
||
|
<Button
|
||
|
key="link"
|
||
|
href="https://google.com"
|
||
|
type="primary"
|
||
|
loading={loading}
|
||
|
onClick={handleOk}
|
||
|
>
|
||
|
Search on Google
|
||
|
</Button>,
|
||
|
]}
|
||
|
>
|
||
|
<p>Some contents...</p>
|
||
|
<p>Some contents...</p>
|
||
|
<p>Some contents...</p>
|
||
|
<p>Some contents...</p>
|
||
|
<p>Some contents...</p>
|
||
|
</Modal>
|
||
|
</>
|
||
|
);
|
||
|
};
|
||
|
|
||
|
export default App;
|