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
|
|
|
|
|
2015-11-10 16:07:23 +08:00
|
|
|
使用 `visible` 属性控制浮层显示。
|
|
|
|
|
2016-08-26 14:42:41 +08:00
|
|
|
## en-US
|
|
|
|
|
|
|
|
Use `visible` prop to control the display of the card.
|
|
|
|
|
2019-05-07 14:57:32 +08:00
|
|
|
```jsx
|
2015-11-10 16:07:23 +08:00
|
|
|
import { Popover, Button } from 'antd';
|
|
|
|
|
2017-02-20 22:06:12 +08:00
|
|
|
class App extends React.Component {
|
|
|
|
state = {
|
|
|
|
visible: false,
|
2019-05-07 14:57:32 +08:00
|
|
|
};
|
2018-06-27 15:55:04 +08:00
|
|
|
|
2017-02-20 22:06:12 +08:00
|
|
|
hide = () => {
|
2015-11-10 16:07:23 +08:00
|
|
|
this.setState({
|
2016-05-11 09:32:33 +08:00
|
|
|
visible: false,
|
2015-11-10 16:07:23 +08:00
|
|
|
});
|
2019-05-07 14:57:32 +08:00
|
|
|
};
|
2018-06-27 15:55:04 +08:00
|
|
|
|
2019-05-07 14:57:32 +08:00
|
|
|
handleVisibleChange = visible => {
|
2015-11-10 16:07:23 +08:00
|
|
|
this.setState({ visible });
|
2019-05-07 14:57:32 +08:00
|
|
|
};
|
2018-06-27 15:55:04 +08:00
|
|
|
|
2015-11-10 16:07:23 +08:00
|
|
|
render() {
|
2016-01-07 16:29:12 +08:00
|
|
|
return (
|
2016-10-07 15:20:10 +08:00
|
|
|
<Popover
|
|
|
|
content={<a onClick={this.hide}>Close</a>}
|
|
|
|
title="Title"
|
|
|
|
trigger="click"
|
|
|
|
visible={this.state.visible}
|
|
|
|
onVisibleChange={this.handleVisibleChange}
|
2016-06-06 13:54:10 +08:00
|
|
|
>
|
2017-01-25 21:27:14 +08:00
|
|
|
<Button type="primary">Click me</Button>
|
2016-01-07 16:29:12 +08:00
|
|
|
</Popover>
|
|
|
|
);
|
2017-02-20 22:06:12 +08:00
|
|
|
}
|
|
|
|
}
|
2015-11-10 16:07:23 +08:00
|
|
|
|
2015-12-29 12:08:58 +08:00
|
|
|
ReactDOM.render(<App />, mountNode);
|
2019-05-07 14:57:32 +08:00
|
|
|
```
|