mirror of
https://gitee.com/ant-design/ant-design.git
synced 2024-12-15 17:31:25 +08:00
2341a25d91
* more refactor * chore: motion support * chore: tmp test * test: Hooks * chore: static function * tmp of it * all of it * mv prefix * chore: clean up * chore: clean up * more test case * test: all base test * test: all test case * init * refactor: rm notification.open instance related code * follow up * refactor: singlton * test: notification test case * refactor to destroy * refactor: message base * test: part test case * test: more * test: more * test: all test * chore: clean up * docs: reorder * chore: fix lint * test: fix test case * chore: add act * chore: back * chore: fix style * test: notification test * test: more and more * test: fix more test * test: index * test: more & more * test: fix placement * test: fix coverage * chore: clean up * chore: bundle size * fix: 17 * chore: more * test: message * test: more test * fix: lint * test: rm class in static * chore: clean up * test: coverage * chore: fix lint
53 lines
1.1 KiB
Markdown
53 lines
1.1 KiB
Markdown
---
|
|
order: 3
|
|
title:
|
|
zh-CN: 自定义按钮
|
|
en-US: Custom close button
|
|
---
|
|
|
|
## zh-CN
|
|
|
|
自定义关闭按钮的样式和文字。
|
|
|
|
## en-US
|
|
|
|
To customize the style or font of the close button.
|
|
|
|
```jsx
|
|
import { Button, notification, Space } from 'antd';
|
|
|
|
const close = () => {
|
|
console.log(
|
|
'Notification was closed. Either the close button was clicked or duration time elapsed.',
|
|
);
|
|
};
|
|
|
|
const openNotification = () => {
|
|
const key = `open${Date.now()}`;
|
|
const btn = (
|
|
<Space>
|
|
<Button type="link" size="small" onClick={() => notification.destroy()}>
|
|
Destroy All
|
|
</Button>
|
|
<Button type="primary" size="small" onClick={() => notification.destroy(key)}>
|
|
Confirm
|
|
</Button>
|
|
</Space>
|
|
);
|
|
notification.open({
|
|
message: 'Notification Title',
|
|
description:
|
|
'A function will be be called after the notification is closed (automatically after the "duration" time of manually).',
|
|
btn,
|
|
key,
|
|
onClose: close,
|
|
});
|
|
};
|
|
|
|
export default () => (
|
|
<Button type="primary" onClick={openNotification}>
|
|
Open the notification box
|
|
</Button>
|
|
);
|
|
```
|