Card 提示
将信息聚合在卡片容器中展示。
基础用法
卡片包含标题,内容以及操作区域。
Card 组件由 header 和 body 组成。 header 是可选的,其内容取决于一个具名的 slot。
标题
List item 1
List item 2
List item 3
List item 4
header 插槽
List item 1
List item 2
List item 3
List item 4
no header
List item 1
List item 2
List item 3
List item 4
List item 1
List item 2
List item 3
List item 4
<template>
<zg-card class="mb" bordered header="标题">
<div v-for="o in 4" :key="o" class="text item">{{ 'List item ' + o }}</div>
</zg-card>
<zg-card class="mb" bordered divider shadow="hover">
<template #header>
<div class="card-header">
<span>header 插槽</span>
<zg-button class="button" text>Operation button</zg-button>
</div>
</template>
<div v-for="o in 4" :key="o" class="text item">{{ 'List item ' + o }}</div>
</zg-card>
<div class="mb">no header</div>
<zg-card class="mb" bordered divider>
<div v-for="o in 4" :key="o" class="text item">{{ 'List item ' + o }}</div>
</zg-card>
<zg-card bordered :bodyStyle="{ color: 'var(--zg-color-primary-light-5)' }">
<div v-for="o in 4" :key="o" class="text item">{{ 'List item ' + o }}</div>
</zg-card>
</template>
<style>
.mb {
margin-bottom: 10px;
}
.card-header {
display: flex;
justify-content: space-between;
align-items: center;
}
</style>
<template>
<zg-card class="mb" bordered header="标题">
<div v-for="o in 4" :key="o" class="text item">{{ 'List item ' + o }}</div>
</zg-card>
<zg-card class="mb" bordered divider shadow="hover">
<template #header>
<div class="card-header">
<span>header 插槽</span>
<zg-button class="button" text>Operation button</zg-button>
</div>
</template>
<div v-for="o in 4" :key="o" class="text item">{{ 'List item ' + o }}</div>
</zg-card>
<div class="mb">no header</div>
<zg-card class="mb" bordered divider>
<div v-for="o in 4" :key="o" class="text item">{{ 'List item ' + o }}</div>
</zg-card>
<zg-card bordered :bodyStyle="{ color: 'var(--zg-color-primary-light-5)' }">
<div v-for="o in 4" :key="o" class="text item">{{ 'List item ' + o }}</div>
</zg-card>
</template>
<style>
.mb {
margin-bottom: 10px;
}
.card-header {
display: flex;
justify-content: space-between;
align-items: center;
}
</style>
Card Attributes
Name | Description | Type | Default |
---|---|---|---|
header | 卡片的标题 你既可以通过设置 header 来修改标题,也可以通过 slot#header 传入 DOM 节点 | string | — |
body-style | body 的 CSS 样式 | object | — |
shadow | 卡片阴影显示时机 | always | never | hover | always |
divider | 标题border bottom | boolean | false |
bordered | 是否有边框 | boolean | false |
Card Slots
插槽名 | Description |
---|---|
default | 自定义默认内容 |
header | 卡片标题内容 |