Skip to content

Card 卡片

用于信息展示的卡片容器。

引入

通过 easycom 自动引入,无需手动注册。

代码演示

基础用法

html
<zq-card title="标题">
  <text>卡片内容</text>
</zq-card>

带图标的标题

通过 icon 属性设置标题左侧图标。

html
<zq-card title="标题" icon="file-text">
  <text>带图标的卡片</text>
</zq-card>

展示额外信息

通过 extra 属性或 extra 插槽在标题右侧展示额外信息。

html
<zq-card title="标题" extra="更多">
  <text>卡片内容</text>
</zq-card>

<zq-card title="标题">
  <template #extra>
    <zq-tag type="primary" size="small" text="标签" />
  </template>
  <text>卡片内容</text>
</zq-card>

封面图片

通过 thumb 属性设置封面图片。

html
<zq-card title="标题" thumb="https://example.com/image.jpg">
  <text>带封面图片的卡片</text>
</zq-card>

底部操作区

通过 footer 插槽设置底部操作区。

html
<zq-card title="标题">
  <text>卡片内容</text>
  <template #footer>
    <zq-button type="primary" size="mini" text="操作" />
    <zq-button size="mini" text="取消" />
  </template>
</zq-card>

自定义头部

通过 header 插槽完全自定义头部内容。

html
<zq-card>
  <template #header>
    <view style="padding: 24rpx 32rpx; display: flex; align-items: center;">
      <zq-avatar :size="'small'" text="A" />
      <text style="margin-left: 16rpx;">自定义头部</text>
    </view>
  </template>
  <text>卡片内容</text>
</zq-card>

边框样式

通过 :shadow="false"border 属性切换为边框样式。

html
<zq-card title="边框卡片" :shadow="false" border>
  <text>使用边框代替阴影</text>
</zq-card>

全宽卡片

通过 full 属性设置为全宽卡片(无左右边距和圆角)。

html
<zq-card title="全宽卡片" full>
  <text>卡片内容</text>
</zq-card>

API

Props

参数说明类型默认值
title卡片标题string''
icon标题左侧图标名称string''
extra标题右侧额外信息string''
thumb封面图片地址string''
shadow是否显示阴影booleantrue
border是否显示边框booleanfalse
full是否为全宽模式(无边距和圆角)booleanfalse

Events

事件名说明回调参数
click点击卡片时触发event: Event

Slots

名称说明
default卡片主体内容
header自定义头部内容(会覆盖 titleiconextra
extra自定义标题右侧内容
footer底部操作区内容

主题定制

变量名说明
--color-bg-card卡片背景色
--color-text-primary标题/图标颜色
--color-text-secondary额外信息文字颜色
--color-divider头部/底部分割线颜色

Released under the MIT License.