2016-03-31 09:40:55 +08:00
|
|
|
---
|
|
|
|
order: 2
|
2016-07-04 10:44:55 +08:00
|
|
|
title:
|
|
|
|
zh-CN: 修改延时
|
|
|
|
en-US: Customize duration
|
2016-03-31 09:40:55 +08:00
|
|
|
---
|
2015-07-11 11:27:10 +08:00
|
|
|
|
2016-07-04 10:44:55 +08:00
|
|
|
## zh-CN
|
|
|
|
|
2017-10-17 21:03:23 +08:00
|
|
|
自定义时长 `10s`,默认时长为 `3s`。
|
2015-07-11 11:27:10 +08:00
|
|
|
|
2016-07-04 10:44:55 +08:00
|
|
|
## en-US
|
|
|
|
|
2017-10-17 21:03:23 +08:00
|
|
|
Customize message display duration from default `3s` to `10s`.
|
2016-07-04 10:44:55 +08:00
|
|
|
|
2022-05-19 09:46:26 +08:00
|
|
|
```tsx
|
2022-05-21 22:14:15 +08:00
|
|
|
import { Button, message } from 'antd';
|
2022-05-19 09:46:26 +08:00
|
|
|
import React from 'react';
|
2015-07-11 11:27:10 +08:00
|
|
|
|
2022-05-26 09:53:08 +08:00
|
|
|
const App: React.FC = () => {
|
|
|
|
const [messageApi, contextHolder] = message.useMessage();
|
|
|
|
|
|
|
|
const success = () => {
|
|
|
|
messageApi.open({
|
|
|
|
type: 'success',
|
|
|
|
content: 'This is a prompt message for success, and it will disappear in 10 seconds',
|
|
|
|
duration: 10,
|
|
|
|
});
|
|
|
|
};
|
|
|
|
|
|
|
|
return (
|
|
|
|
<>
|
|
|
|
{contextHolder}
|
|
|
|
<Button onClick={success}>Customized display duration</Button>
|
|
|
|
</>
|
|
|
|
);
|
2015-07-11 18:00:58 +08:00
|
|
|
};
|
2015-07-11 11:27:10 +08:00
|
|
|
|
2022-05-19 09:46:26 +08:00
|
|
|
export default App;
|
2019-05-07 14:57:32 +08:00
|
|
|
```
|