ant-design/components/alert/demo/smooth-closed.md

47 lines
701 B
Markdown
Raw Normal View History

---
order: 7
title:
zh-CN: 平滑地卸载
en-US: Smoothly Unmount
---
## zh-CN
2018-09-16 18:36:17 +08:00
平滑、自然的卸载提示。
## en-US
2019-04-19 20:48:29 +08:00
Smoothly unmount Alert upon close.
2019-05-07 14:57:32 +08:00
```jsx
import { Alert } from 'antd';
class App extends React.Component {
state = {
visible: true,
2019-05-07 14:57:32 +08:00
};
2018-06-27 15:55:04 +08:00
handleClose = () => {
this.setState({ visible: false });
2019-05-07 14:57:32 +08:00
};
2018-06-27 15:55:04 +08:00
render() {
return (
<div>
2019-05-07 14:57:32 +08:00
{this.state.visible ? (
<Alert
message="Alert Message Text"
type="success"
closable
afterClose={this.handleClose}
/>
) : null}
<p>placeholder text here</p>
</div>
);
}
}
2019-05-07 14:57:32 +08:00
ReactDOM.render(<App />, mountNode);
```