2016-03-31 09:40:55 +08:00
|
|
|
---
|
|
|
|
order: 3
|
2016-08-26 14:42:41 +08:00
|
|
|
title:
|
|
|
|
zh-CN: 从浮层内关闭
|
|
|
|
en-US: Controlling the close of the dialog
|
2016-03-31 09:40:55 +08:00
|
|
|
---
|
2015-11-10 16:07:23 +08:00
|
|
|
|
2016-08-26 14:42:41 +08:00
|
|
|
## zh-CN
|
|
|
|
|
2022-08-24 21:34:17 +08:00
|
|
|
使用 `open` 属性控制浮层显示。
|
2015-11-10 16:07:23 +08:00
|
|
|
|
2016-08-26 14:42:41 +08:00
|
|
|
## en-US
|
|
|
|
|
2022-08-24 21:34:17 +08:00
|
|
|
Use `open` prop to control the display of the card.
|
2016-08-26 14:42:41 +08:00
|
|
|
|
2022-05-19 09:46:26 +08:00
|
|
|
```tsx
|
2022-05-21 22:14:15 +08:00
|
|
|
import { Button, Popover } from 'antd';
|
2022-05-19 09:46:26 +08:00
|
|
|
import React, { useState } from 'react';
|
2015-11-10 16:07:23 +08:00
|
|
|
|
2022-05-19 09:46:26 +08:00
|
|
|
const App: React.FC = () => {
|
2022-08-24 21:34:17 +08:00
|
|
|
const [open, setOpen] = useState(false);
|
2018-06-27 15:55:04 +08:00
|
|
|
|
2022-05-19 09:46:26 +08:00
|
|
|
const hide = () => {
|
2022-08-24 21:34:17 +08:00
|
|
|
setOpen(false);
|
2019-05-07 14:57:32 +08:00
|
|
|
};
|
2018-06-27 15:55:04 +08:00
|
|
|
|
2022-08-24 21:34:17 +08:00
|
|
|
const handleOpenChange = (newOpen: boolean) => {
|
|
|
|
setOpen(newOpen);
|
2019-05-07 14:57:32 +08:00
|
|
|
};
|
2018-06-27 15:55:04 +08:00
|
|
|
|
2022-05-19 09:46:26 +08:00
|
|
|
return (
|
|
|
|
<Popover
|
|
|
|
content={<a onClick={hide}>Close</a>}
|
|
|
|
title="Title"
|
|
|
|
trigger="click"
|
2022-08-24 21:34:17 +08:00
|
|
|
open={open}
|
|
|
|
onOpenChange={handleOpenChange}
|
2022-05-19 09:46:26 +08:00
|
|
|
>
|
|
|
|
<Button type="primary">Click me</Button>
|
|
|
|
</Popover>
|
|
|
|
);
|
|
|
|
};
|
2015-11-10 16:07:23 +08:00
|
|
|
|
2022-04-15 16:20:56 +08:00
|
|
|
export default App;
|
2019-05-07 14:57:32 +08:00
|
|
|
```
|