mirror of
https://github.com/ant-design/ant-design.git
synced 2024-12-22 14:44:47 +08:00
48 lines
843 B
Markdown
Executable File
48 lines
843 B
Markdown
Executable File
---
|
|
order: 3
|
|
title:
|
|
zh-CN: 从浮层内关闭
|
|
en-US: Controlling the close of the dialog
|
|
---
|
|
|
|
## zh-CN
|
|
|
|
使用 `visible` 属性控制浮层显示。
|
|
|
|
## en-US
|
|
|
|
Use `visible` prop to control the display of the card.
|
|
|
|
````jsx
|
|
import { Popover, Button } from 'antd';
|
|
|
|
class App extends React.Component {
|
|
state = {
|
|
visible: false,
|
|
}
|
|
hide = () => {
|
|
this.setState({
|
|
visible: false,
|
|
});
|
|
}
|
|
handleVisibleChange = (visible) => {
|
|
this.setState({ visible });
|
|
}
|
|
render() {
|
|
return (
|
|
<Popover
|
|
content={<a onClick={this.hide}>Close</a>}
|
|
title="Title"
|
|
trigger="click"
|
|
visible={this.state.visible}
|
|
onVisibleChange={this.handleVisibleChange}
|
|
>
|
|
<Button type="primary">Click me</Button>
|
|
</Popover>
|
|
);
|
|
}
|
|
}
|
|
|
|
ReactDOM.render(<App />, mountNode);
|
|
````
|