2016-03-31 09:40:55 +08:00
|
|
|
|
---
|
|
|
|
|
order: 3
|
2016-07-04 10:44:55 +08:00
|
|
|
|
title:
|
|
|
|
|
zh-CN: 加载中
|
2019-04-19 22:35:06 +08:00
|
|
|
|
en-US: Message with loading indicator
|
2016-03-31 09:40:55 +08:00
|
|
|
|
---
|
2015-09-07 12:27:09 +08:00
|
|
|
|
|
2016-07-04 10:44:55 +08:00
|
|
|
|
## zh-CN
|
|
|
|
|
|
2015-09-07 12:27:09 +08:00
|
|
|
|
进行全局 loading,异步自行移除。
|
|
|
|
|
|
2016-07-04 10:44:55 +08:00
|
|
|
|
## en-US
|
|
|
|
|
|
|
|
|
|
Display a global loading indicator, which is dismissed by itself asynchronously.
|
|
|
|
|
|
2022-05-19 09:46:26 +08:00
|
|
|
|
```tsx
|
2022-11-18 16:37:24 +08:00
|
|
|
|
import { Button, message, Space } from 'antd';
|
2022-05-19 09:46:26 +08:00
|
|
|
|
import React from 'react';
|
2015-09-07 12:27:09 +08:00
|
|
|
|
|
2016-07-21 18:05:15 +08:00
|
|
|
|
const success = () => {
|
2022-11-18 16:37:24 +08:00
|
|
|
|
const hide = message.loading('Action in progress..', 0, () => {
|
|
|
|
|
message.success('loading had closed');
|
|
|
|
|
});
|
2016-07-04 10:44:55 +08:00
|
|
|
|
// Dismiss manually and asynchronously
|
2015-09-07 12:27:09 +08:00
|
|
|
|
setTimeout(hide, 2500);
|
|
|
|
|
};
|
|
|
|
|
|
2022-11-18 16:37:24 +08:00
|
|
|
|
const success2 = () => {
|
|
|
|
|
message.loading('Action in progress..', 3, () => {
|
|
|
|
|
message.success('loading had closed');
|
|
|
|
|
});
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
const App: React.FC = () => (
|
|
|
|
|
<Space>
|
|
|
|
|
<Button onClick={success}>Display a loading indicator</Button>
|
|
|
|
|
<Button onClick={success2}>Display a loading and auto hide</Button>
|
|
|
|
|
</Space>
|
|
|
|
|
);
|
2022-05-19 09:46:26 +08:00
|
|
|
|
|
|
|
|
|
export default App;
|
2019-05-07 14:57:32 +08:00
|
|
|
|
```
|