本代码展示了一个基于 Vue 和 Ant Design 的卡片组件,用于创建图片画廊和愿望清单。此组件可用于各种应用场景,例如在线购物、社交媒体和个人主页。
此代码实现了以下基本功能:
图片画廊
<a-upload
:action="''"
:default-file-list="defaultFileList"
:show-upload-list="false"
:multiple="true"
:max-count="3"
>
<a-button type="primary" size="small">Upload</a-button>
</a-upload>
此代码使用 a-upload
组件创建了一个图片上传器。它配置了 action
、defaultFileList
、show-upload-list
、multiple
和 max-count
属性,以控制上传行为。
<a-list
:grid="{ gutter: 16, column: 3 }"
:data-source="imageList"
:item-layout="renderItem"
/>
此代码使用 a-list
组件创建了一个图片画廊。它配置了 grid
和 data-source
属性,以显示图像列表。renderItem
函数定义了每个图像的布局。
愿望清单
<div class="flex justify-between items-center">
<div class="text-xl font-semibold">Whislist</div>
<div class="flex items-center">
<a-tag color="green" class="mr-2">Bakso Super</a-tag>
<a-tag color="orange">Mushrooms</a-tag>
<a-tag color="blue">Veggie</a-tag>
</div>
</div>
此代码使用 a-tag
组件创建了一个愿望清单。它使用 color
属性设置不同标签的颜色。
<a-list
:item-layout="renderItem"
:data-source="foodList"
/>
此代码使用 a-list
组件创建了一个愿望清单。它配置了 item-layout
和 data-source
属性,以显示食物项目列表。renderItem
函数定义了每个食物项目的布局。
开发这段代码的过程让我深入了解了 Vue 和 Ant Design 的功能。我学会了如何使用 a-upload
组件处理文件上传,以及如何使用 a-list
组件创建动态列表。
未来,此卡片功能可以扩展和优化,例如: