ant-design/components/popover/demo/control.md

51 lines
921 B
Markdown
Raw Normal View History

2016-03-31 09:40:55 +08:00
---
order: 3
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
## zh-CN
2015-11-10 16:07:23 +08:00
使用 `visible` 属性控制浮层显示。
## en-US
Use `visible` prop to control the display of the card.
2015-11-10 16:07:23 +08:00
````jsx
import { Popover, Button } from 'antd';
const App = React.createClass({
getInitialState() {
return {
2016-05-11 09:32:33 +08:00
visible: false,
2015-11-10 16:07:23 +08:00
};
},
hide() {
this.setState({
2016-05-11 09:32:33 +08:00
visible: false,
2015-11-10 16:07:23 +08:00
});
},
handleVisibleChange(visible) {
this.setState({ visible });
},
render() {
const content = (
<div>
<a onClick={this.hide}>关闭卡片</a>
</div>
);
return (
<Popover content={content} title="标题" trigger="click"
visible={this.state.visible} onVisibleChange={this.handleVisibleChange}
>
<Button type="primary">点击弹出卡片</Button>
</Popover>
);
2016-05-11 09:32:33 +08:00
},
2015-11-10 16:07:23 +08:00
});
ReactDOM.render(<App />, mountNode);
2015-11-10 16:07:23 +08:00
````