2015-11-10 16:07:23 +08:00
|
|
|
# 从浮层内关闭
|
|
|
|
|
|
|
|
- order: 3
|
|
|
|
|
|
|
|
使用 `visible` 属性控制浮层显示。
|
|
|
|
|
|
|
|
---
|
|
|
|
|
|
|
|
````jsx
|
|
|
|
import { Popover, Button } from 'antd';
|
|
|
|
|
|
|
|
const App = React.createClass({
|
|
|
|
getInitialState() {
|
|
|
|
return {
|
|
|
|
visible: false
|
|
|
|
};
|
|
|
|
},
|
|
|
|
hide() {
|
|
|
|
this.setState({
|
|
|
|
visible: false
|
|
|
|
});
|
|
|
|
},
|
|
|
|
handleVisibleChange(visible) {
|
|
|
|
this.setState({ visible });
|
|
|
|
},
|
|
|
|
render() {
|
2016-01-07 16:29:12 +08:00
|
|
|
const content = (
|
|
|
|
<div>
|
|
|
|
<a onClick={this.hide}>关闭卡片</a>
|
|
|
|
</div>
|
|
|
|
);
|
|
|
|
return (
|
|
|
|
<Popover overlay={content} title="标题" trigger="click"
|
2016-01-08 14:41:05 +08:00
|
|
|
visible={this.state.visible} onVisibleChange={this.handleVisibleChange}>
|
2016-01-07 16:29:12 +08:00
|
|
|
<Button type="primary">点击弹出卡片</Button>
|
|
|
|
</Popover>
|
|
|
|
);
|
2015-11-10 16:07:23 +08:00
|
|
|
}
|
|
|
|
});
|
|
|
|
|
2015-12-29 12:08:58 +08:00
|
|
|
ReactDOM.render(<App />, mountNode);
|
2015-11-10 16:07:23 +08:00
|
|
|
````
|