mirror of
https://github.com/ant-design/ant-design.git
synced 2024-12-02 15:59:38 +08:00
e361b30ded
* 🎬 update Card demo * refactor card code * 🎬 update Tabs demo * update snapshot
73 lines
1.6 KiB
Markdown
73 lines
1.6 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 { Skeleton, Switch, Card, Avatar } from 'antd';
|
|
import { EditOutlined, EllipsisOutlined, SettingOutlined } from '@ant-design/icons';
|
|
|
|
const { Meta } = Card;
|
|
|
|
class App extends React.Component {
|
|
state = {
|
|
loading: true,
|
|
};
|
|
|
|
onChange = checked => {
|
|
this.setState({ loading: !checked });
|
|
};
|
|
|
|
render() {
|
|
const { loading } = this.state;
|
|
|
|
return (
|
|
<>
|
|
<Switch checked={!loading} onChange={this.onChange} />
|
|
|
|
<Card style={{ width: 300, marginTop: 16 }} loading={loading}>
|
|
<Meta
|
|
avatar={
|
|
<Avatar src="https://zos.alipayobjects.com/rmsportal/ODTLcjxAfvqbxHnVXCYX.png" />
|
|
}
|
|
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://zos.alipayobjects.com/rmsportal/ODTLcjxAfvqbxHnVXCYX.png" />
|
|
}
|
|
title="Card title"
|
|
description="This is the description"
|
|
/>
|
|
</Skeleton>
|
|
</Card>
|
|
</>
|
|
);
|
|
}
|
|
}
|
|
|
|
ReactDOM.render(<App />, mountNode);
|
|
```
|