ant-design/components/notification/demo/duration.md

34 lines
957 B
Markdown
Raw Normal View History

2016-03-31 09:40:55 +08:00
---
order: 1
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.
2017-02-13 10:55:53 +08:00
````jsx
import { Button, notification } from 'antd';
2015-08-03 15:17:12 +08:00
2016-12-14 17:57:15 +08:00
const openNotification = () => {
const args = {
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(
2018-06-27 15:55:04 +08:00
<Button type="primary" onClick={openNotification}>Open the notification box</Button>,
mountNode);
2015-08-04 15:16:10 +08:00
````