mirror of
https://gitee.com/ant-design/ant-design.git
synced 2024-12-05 05:28:20 +08:00
f5831f121d
* docs(badge): replace class component with hooks * docs(button): replace class component with hooks * docs(calendar): replace class component with hooks * docs(card): replace class component with hooks * docs(button): replace class component with hooks * chore(deps): remove webpack devDependencies
62 lines
1.4 KiB
Markdown
62 lines
1.4 KiB
Markdown
---
|
|
order: 5
|
|
title:
|
|
zh-CN: 预加载的卡片
|
|
en-US: Loading card
|
|
---
|
|
|
|
## zh-CN
|
|
|
|
数据读入前会有文本块样式。
|
|
|
|
## en-US
|
|
|
|
Shows a loading indicator while the contents of the card is being fetched.
|
|
|
|
```jsx
|
|
import React, { useState } from 'react';
|
|
import { Skeleton, Switch, Card, Avatar } from 'antd';
|
|
import { EditOutlined, EllipsisOutlined, SettingOutlined } from '@ant-design/icons';
|
|
|
|
const { Meta } = Card;
|
|
|
|
export default () => {
|
|
const [loading, setLoading] = useState(true);
|
|
|
|
const onChange = checked => {
|
|
setLoading(!checked);
|
|
};
|
|
|
|
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>
|
|
<Meta
|
|
avatar={<Avatar src="https://joeschmoe.io/api/v1/random" />}
|
|
title="Card title"
|
|
description="This is the description"
|
|
/>
|
|
</Skeleton>
|
|
</Card>
|
|
</>
|
|
);
|
|
};
|
|
```
|