Skip to content

Card 卡片

介绍

卡片组件用于展示结构化信息,支持图片、标题、描述等内容,常用于列表展示或内容卡片。

导入

js
import Card from '@/components/display/Card.vue'

用法

基础用法

基础卡片包含标题、描述、额外内容和自定义内容区域。

vue
<template>
  <Card title="卡片标题" desc="卡片描述" extra="额外内容" :icon="IconPlaceholder">
    <text>这是一个基础卡片的示例,此处为自定义内容区域,自行控制内容样式。</text>
  </Card>
</template>

通栏展示

设置 radius 为 0 可以实现通栏展示效果。

vue
<template>
  <Card title="卡片标题" extra="额外内容" :radius="0" :icon="IconPlaceholder">
    <text>这是一个基础卡片的示例,此处为自定义内容区域,自行控制内容样式。</text>
  </Card>
</template>

图片卡片

卡片支持添加图片,并可在图片上显示标题、描述等信息。

vue
<template>
  <Card 
    title="NaEasy UI" 
    extra="21分钟"
    :icon="Logo"
    image="https://imengyu.top/assets/images/test/2.jpg"
    imageDesc="NaEasy UI 是一款轻量、简洁的 Uniapp 移动端组件库。"
  />
</template>

内容卡片

可以将图片信息显示在图片下方,适合作为内容卡片使用。

vue
<template>
  <Card 
    :icon="Logo"
    image="https://imengyu.top/assets/images/test/2.jpg"
    imageInfoPosition="bottom"
    imageDesc="NaEasy UI 是一款轻量、简洁的 Uniapp 移动端组件库。"
  >
    <FlexRow :gap="10">
      <Tag type="primary" scheme="light" text="推荐" size="small" />
      <Tag type="primary" scheme="light" text="新文章" size="small" />
    </FlexRow>
  </Card>
</template>

API 参考

Card

卡片组件。

Props

名称说明类型必填默认值
title卡片标题string-
desc卡片描述string-
extra卡片标题额外内容string-
icon卡片图标string-
iconProps卡片图标属性IconProps-
radius卡片圆角number15
backgroundColor卡片背景颜色string'white'
viewProps卡片视图属性FlexProps-
content卡片内容string-
image卡片图片string-
imageProps卡片图片属性ImageProps-
imageHeight卡片图片高度number320
imageTitle卡片图片标题number-
imageDesc卡片图片描述string-
imageExtra卡片图片额外内容string-
imageInfoPosition卡片图片信息位置
* over 图片底部渐变显示
* bottom 图片下方单独显示
'over' | 'bottom''over'

Slots

名称说明
default卡片内容区域,等同于 content 属性
prefix卡片前缀内容
suffix卡片后缀内容
extra卡片标题额外内容,等同于 extra 属性
imageExtra卡片图片额外内容,等同于 imageExtra 属性

Events

名称说明参数
click点击事件$event

主题变量

名称类型默认值说明
CardRadiusnumber15卡片圆角
CardImageDefaultHeightnumber320卡片图片默认高度
CardImageInfoPositionstring'over'卡片图片信息默认位置
CardBackgroundColorstring'white'卡片背景颜色
CardTitlePaddingnumber20卡片标题内边距