Skip to content

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

NameDescriptionTypeDefault
header卡片的标题 你既可以通过设置 header 来修改标题,也可以通过 slot#header 传入 DOM 节点string
body-stylebody 的 CSS 样式object
shadow卡片阴影显示时机always | never | hoveralways
divider标题border bottombooleanfalse
bordered是否有边框booleanfalse

Card Slots

插槽名Description
default自定义默认内容
header卡片标题内容

Released under the MIT License.