2016-03-31 09:40:55 +08:00
|
|
|
---
|
|
|
|
order: 1
|
2016-08-28 17:45:27 +08:00
|
|
|
title:
|
2016-08-17 11:07:02 +08:00
|
|
|
zh-CN: 自动关闭的延时
|
|
|
|
en-US: Duration after which the notification box is closed
|
2016-03-31 09:40:55 +08:00
|
|
|
---
|
2015-08-03 15:17:12 +08:00
|
|
|
|
2016-08-17 11:07:02 +08:00
|
|
|
## zh-CN
|
|
|
|
|
2015-08-29 13:02:37 +08:00
|
|
|
自定义通知框自动关闭的延时,默认`4.5s`,取消自动关闭只要将该值设为 `0` 即可。
|
2015-08-03 15:17:12 +08:00
|
|
|
|
2016-08-17 11:07:02 +08:00
|
|
|
## en-US
|
|
|
|
|
|
|
|
`Duration` can be used to specify how long the notification stays open. After the duration time elapses,
|
|
|
|
the notification closes automatically. If not specified, default value is 4.5 seconds. If you set the value to 0,
|
|
|
|
the notification box will never close automatically.
|
|
|
|
|
2015-08-03 15:17:12 +08:00
|
|
|
````jsx
|
2015-10-28 20:55:49 +08:00
|
|
|
import { Button, notification } from 'antd';
|
2015-08-03 15:17:12 +08:00
|
|
|
|
2016-12-14 17:57:15 +08:00
|
|
|
const openNotification = () => {
|
2015-10-28 20:55:49 +08:00
|
|
|
const args = {
|
2016-08-28 17:45:27 +08:00
|
|
|
message: 'Notification Title',
|
|
|
|
description: 'I will never close automatically. I will be close automatically. I will never close automatically.',
|
2016-05-11 09:32:33 +08:00
|
|
|
duration: 0,
|
2015-08-03 15:17:12 +08:00
|
|
|
};
|
|
|
|
notification.open(args);
|
|
|
|
};
|
|
|
|
|
2015-10-20 16:47:55 +08:00
|
|
|
ReactDOM.render(
|
2016-08-17 11:07:02 +08:00
|
|
|
<Button type="primary" onClick={openNotification}>Open the notification box</Button>
|
2015-12-29 12:08:58 +08:00
|
|
|
, mountNode);
|
2015-08-04 15:16:10 +08:00
|
|
|
````
|