You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

42 lines
784 B

---
order: 3
title: 从浮层内关闭
---
9 years ago
使用 `visible` 属性控制浮层显示。
````jsx
import { Popover, Button } from 'antd';
const App = React.createClass({
getInitialState() {
return {
visible: false,
9 years ago
};
},
hide() {
this.setState({
visible: false,
9 years ago
});
},
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>
);
},
9 years ago
});
ReactDOM.render(<App />, mountNode);
9 years ago
````