ant-design-vue/components/skeleton/demo/list.md

80 lines
2.1 KiB
Markdown
Raw Normal View History

2018-12-10 03:34:51 +00:00
<cn>
#### 列表
在列表组件中使用加载占位符。
</cn>
<us>
#### List
Use skeleton in list component.
</us>
2019-10-09 10:32:23 +00:00
```tpl
2018-12-10 03:34:51 +00:00
<template>
<div>
<a-switch :checked="!loading" @change="onChange" />
2019-09-28 12:45:07 +00:00
<a-list itemLayout="vertical" size="large" :dataSource="listData">
2018-12-10 03:34:51 +00:00
<a-list-item slot="renderItem" slot-scope="item, index" key="item.title">
<template v-if="!loading" slot="actions" v-for="{type, text} in actions">
<span :key="type">
<a-icon :type="type" style="margin-right: 8px" />
{{text}}
</span>
</template>
2019-09-28 12:45:07 +00:00
<img
v-if="!loading"
slot="extra"
width="272"
alt="logo"
src="https://gw.alipayobjects.com/zos/rmsportal/mqaQswcyDLcXyDKnZfES.png"
/>
2018-12-10 03:34:51 +00:00
<a-skeleton :loading="loading" active avatar>
2019-09-28 12:45:07 +00:00
<a-list-item-meta :description="item.description">
2018-12-10 03:34:51 +00:00
<a slot="title" :href="item.href">{{item.title}}</a>
<a-avatar slot="avatar" :src="item.avatar" />
</a-list-item-meta>
{{item.content}}
</a-skeleton>
</a-list-item>
</a-list>
</div>
</template>
<script>
const listData = [];
for (let i = 0; i < 3; i++) {
listData.push({
2019-02-16 08:51:21 +00:00
href: 'https://vue.ant.design/',
2018-12-10 03:34:51 +00:00
title: `ant design vue part ${i}`,
avatar: 'https://zos.alipayobjects.com/rmsportal/ODTLcjxAfvqbxHnVXCYX.png',
2019-09-28 12:45:07 +00:00
description:
'Ant Design, a design language for background applications, is refined by Ant UED Team.',
content:
'We supply a series of design principles, practical patterns and high quality design resources (Sketch and Axure), to help people create their product prototypes beautifully and efficiently.',
2018-12-10 03:34:51 +00:00
});
}
export default {
data() {
return {
loading: true,
listData,
actions: [
{ type: 'star-o', text: '156' },
{ type: 'like-o', text: '156' },
{ type: 'message', text: '2' },
],
2019-09-28 12:45:07 +00:00
};
2018-12-10 03:34:51 +00:00
},
methods: {
onChange(checked) {
2019-09-28 12:45:07 +00:00
this.loading = !checked;
},
},
};
2018-12-10 03:34:51 +00:00
</script>
<style>
2019-09-28 12:45:07 +00:00
.skeleton-demo {
border: 1px solid #f4f4f4;
}
2018-12-10 03:34:51 +00:00
</style>
```