Card 卡片
将信息聚合在卡片容器中展示。
基础用法
卡片包含标题,内容以及操作区域。
Card 组件由 header body 和 footer组成。 header 和 footer是可选的,其内容取决于一个具名的 slot。
Card name
List item 1
List item 2
List item 3
List item 4
<template>
<Card class="card-box">
<template #header>
<div class="card-header">
<span>Card name</span>
<Button class="button" text>Operation button</Button>
</div>
</template>
<div v-for="o in 4" :key="o" class="text item">{{ 'List item ' + o }}</div>
<template #footer>Footer content</template>
</Card>
</template>
<script setup>
import Card from '@/components/Card/Card.vue'
import Button from '@/components/Button/Button.vue'
</script>
<style scoped>
.card-box {
margin: 20px;
}
.card-header {
display: flex;
justify-content: space-between;
align-items: center;
}
.text {
font-size: 14px;
}
.item {
margin-bottom: 18px;
}
</style>简单卡片
卡片可以只有内容区域。
List item 1
List item 2
List item 3
List item 4
<template>
<Card class="card-box">
<div v-for="o in 4" :key="o" class="text item">{{ 'List item ' + o }}</div>
</Card>
</template>
<script setup>
import Card from '@/components/Card/Card.vue'
</script>
<style scoped>
.card-box {
margin: 20px;
}
.text {
font-size: 14px;
}
.item {
margin-bottom: 18px;
}
</style>有图片内容的卡片
可配置定义更丰富的内容展示。
配置 body-style 属性来自定义 body 部分的样式

泰菲
泰菲是一只由杰瑞收养的小灰鼠,它非常贪吃,喜欢卖萌。它的名字来源于杰瑞的昵称,而杰瑞并没有一个正确的名字,所以只能称呼它为大表哥。而杰瑞的侄子佩克斯则是一个有趣的角色,他的表叔佩克斯有着非凡的琴弦技术,而他的侄子泰菲则是一个调皮捣蛋的形象。
<template>
<Card class="card-box" :bodyStyle="{ padding: 0 }">
<img src="../../public/1.png" alt="" />
<div class="content">
<h4>泰菲</h4>
<p>泰菲是一只由杰瑞收养的小灰鼠,它非常贪吃,喜欢卖萌。它的名字来源于杰瑞的昵称,而杰瑞并没有一个正确的名字,所以只能称呼它为大表哥。而杰瑞的侄子佩克斯则是一个有趣的角色,他的表叔佩克斯有着非凡的琴弦技术,而他的侄子泰菲则是一个调皮捣蛋的形象。</p>
</div>
</Card>
</template>
<script setup>
import Card from '@/components/Card/Card.vue'
</script>
<style scoped>
.card-box {
margin: 20px;
}
.content {
padding: 10px;
}
</style>参数
| 属性 | 说明 | 类型 | 默认值 |
|---|---|---|---|
| header | 卡片的标题 你既可以通过设置 header 来修改标题,也可以通过 slot#header 传入 DOM 节点 | string | |
| footer | 卡片页脚。 你既可以通过设置 header 来修改标题,也可以通过 slot#footer 传入 DOM 节点 | string | |
| body-style | body 的 CSS 样式 | object | |
| body-class | body 的自定义类名 |
