2016-03-31 09:40:55 +08:00
|
|
|
---
|
2016-04-10 15:38:52 +08:00
|
|
|
order: 5
|
2016-05-26 17:46:55 +08:00
|
|
|
title:
|
|
|
|
zh-CN: 预加载的卡片
|
|
|
|
en-US: Loading card
|
2016-03-31 09:40:55 +08:00
|
|
|
---
|
2016-02-22 16:25:13 +08:00
|
|
|
|
2016-05-26 17:46:55 +08:00
|
|
|
## zh-CN
|
|
|
|
|
2016-02-22 16:25:13 +08:00
|
|
|
数据读入前会有文本块样式。
|
|
|
|
|
2016-05-26 17:46:55 +08:00
|
|
|
## en-US
|
|
|
|
|
2016-12-06 16:46:12 +08:00
|
|
|
Shows a loading indicator while the contents of the card is being fetched.
|
2016-05-26 17:46:55 +08:00
|
|
|
|
2022-05-19 09:46:26 +08:00
|
|
|
```tsx
|
2019-11-28 12:34:33 +08:00
|
|
|
import { EditOutlined, EllipsisOutlined, SettingOutlined } from '@ant-design/icons';
|
2022-05-23 14:37:16 +08:00
|
|
|
import { Avatar, Card, Skeleton, Switch } from 'antd';
|
|
|
|
import React, { useState } from 'react';
|
2018-04-20 10:44:33 +08:00
|
|
|
|
2018-08-22 23:34:36 +08:00
|
|
|
const { Meta } = Card;
|
|
|
|
|
2022-05-19 09:46:26 +08:00
|
|
|
const App: React.FC = () => {
|
2022-05-10 13:00:31 +08:00
|
|
|
const [loading, setLoading] = useState(true);
|
2018-04-20 10:44:33 +08:00
|
|
|
|
2022-05-19 09:46:26 +08:00
|
|
|
const onChange = (checked: boolean) => {
|
2022-05-10 13:00:31 +08:00
|
|
|
setLoading(!checked);
|
2019-05-07 14:57:32 +08:00
|
|
|
};
|
2018-04-20 10:44:33 +08:00
|
|
|
|
2022-05-10 13:00:31 +08:00
|
|
|
return (
|
|
|
|
<>
|
|
|
|
<Switch checked={!loading} onChange={onChange} />
|
|
|
|
|
|
|
|
<Card style={{ width: 300, marginTop: 16 }} loading={loading}>
|
|
|
|
<Meta
|
|
|
|
avatar={<Avatar src="https://joeschmoe.io/api/v1/random" />}
|
|
|
|
title="Card title"
|
|
|
|
description="This is the description"
|
|
|
|
/>
|
|
|
|
</Card>
|
|
|
|
|
|
|
|
<Card
|
|
|
|
style={{ width: 300, marginTop: 16 }}
|
|
|
|
actions={[
|
|
|
|
<SettingOutlined key="setting" />,
|
|
|
|
<EditOutlined key="edit" />,
|
|
|
|
<EllipsisOutlined key="ellipsis" />,
|
|
|
|
]}
|
|
|
|
>
|
|
|
|
<Skeleton loading={loading} avatar active>
|
2018-09-02 16:09:47 +08:00
|
|
|
<Meta
|
2021-10-14 12:09:07 +08:00
|
|
|
avatar={<Avatar src="https://joeschmoe.io/api/v1/random" />}
|
2018-09-02 16:09:47 +08:00
|
|
|
title="Card title"
|
|
|
|
description="This is the description"
|
|
|
|
/>
|
2022-05-10 13:00:31 +08:00
|
|
|
</Skeleton>
|
|
|
|
</Card>
|
|
|
|
</>
|
|
|
|
);
|
|
|
|
};
|
2022-05-19 09:46:26 +08:00
|
|
|
|
|
|
|
export default App;
|
2019-05-07 14:57:32 +08:00
|
|
|
```
|