ant-design/components/alert/demo/closable.md
偏右 2beb28518c
test: Alert and AutoComplete test coverage (#24004)
* 🔨 refactor demo code style

* refactor alert code and fix test cov

* add test case for AutoComplete

* fix test
2020-05-09 19:32:02 +08:00

42 lines
788 B
Markdown

---
order: 2
title:
zh-CN: 可关闭的警告提示
en-US: Closable
---
## zh-CN
显示关闭按钮,点击可关闭警告提示。
## en-US
To show close button.
```tsx
import { Alert } from 'antd';
const onClose = (e: React.MouseEvent<HTMLButtonElement, MouseEvent>) => {
console.log(e, 'I was closed.');
};
ReactDOM.render(
<>
<Alert
message="Warning Text Warning Text Warning TextW arning Text Warning Text Warning TextWarning Text"
type="warning"
closable
onClose={onClose}
/>
<Alert
message="Error Text"
description="Error Description Error Description Error Description Error Description Error Description Error Description"
type="error"
closable
onClose={onClose}
/>
</>,
mountNode,
);
```