Card
Groups a cover, headings, content and actions; loading uses Skeleton.
Import
Use <hui-card> after configuring uni-app easycom. Import public types and functions from @nscode/handy-uni. Ordinary Vue applications install the @nscode/handy-uni/web preview plugin.
Examples
Each example is standalone. Controls show the current value or event result on the page.
<template>
<view>
<hui-space direction="vertical" fill>
<hui-card
custom-class="hui-space__item"
title="卡片 / Card"
subtitle="说明 / Description"
extra="更多 / More"
:cover="cover"
shadow="always"
clickable
@click="lastEvent = 'card click'"
>
<text>正文 / Body</text><template #footer>页脚 / Footer</template>
<template #actions
><hui-button @click.stop="lastEvent = 'action'">操作 / Action</hui-button></template
>
</hui-card>
<hui-card custom-class="hui-space__item" title="加载 / Loading" loading bordered />
<hui-card custom-class="hui-space__item" :cover="cover" cover-position="left" size="small"
>侧封面 / Side cover</hui-card
>
<text class="hui-space__item">{{ lastEvent }}</text>
</hui-space>
</view>
</template>
<script setup lang="ts">
import { ref } from 'vue'
const lastEvent = ref('尚无事件 / No event')
const cover =
'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAADAAAAAgCAIAAADbtmxLAAAB/0lEQVR4nM3QVUIUABAA0DmEgCDYgoCBqEgoiIiBSkp3d9d2dy/d3d3d3SWooBJ2YAL/XmPeER4ccyaoupKOu1M0PGma3oyTvqzT/pyzgbzzwQLtUNHFcIlepOxStOJKbJpBfIZhYtaN5Byj1DxjYoEpueg2tcScXnaXWXGPXXWfW/OAX/dI2GAjbnoqbbGVt9krOxzTu55n9rhk97nlDnjkD3kVjvgUj/mVTgSUTwVVzoRUz4XVLkTUL0U1rsQ0r8W1rie0vwQVF6KaG1ndg3rCi67lwzzlxz4TwD0XxL8QItQJE+tGSPWj5JdjlFfj0q8lZF5Pyr6ZknuLkG9CKjSjFN+hlVowyi1ZlVacamte7UNB/WNR4xNJ8zNZq52i3SGt0ymj2zmr1zWn3z1v0LNg2Lto1Ldk3L9sMrBiOrhqNrRmPrxuMbJhObppNbblRXzbRmLHK0DVk9T5GlD1JHdtAqqelO4tQNWT2vMGUPUQet8Cqh5i3ztA1UPq3wZUPeSBHUDVQxncBVQ91KE9QNVDG34PqHroIx8AVQ9j9COg6mGOfQJUPazxz4Cqhz3xBVD1cCa/Aqoe7tQ3QNXDm/4OqHr4Mz8AVY9gdh9Q9QjnfgKqHtH8L0DVI174Dah6JIt/AFWPdOkvoOqRLf8DVD3ylQNA1aNYPQRUPcq1o/83VquIElJ47QAAAABJRU5ErkJggg=='
</script>
Props
| Prop | Type | Default | Details |
|---|---|---|---|
title | string | — | Heading text, or the title-placeholder switch for Skeleton. |
subtitle | string | — | Secondary heading. |
extra | string | — | Additional header text. |
cover | string | UniRemoteFile | — | Cover URL or remote file. |
coverRatio | number | 16 / 9 | Cover width-to-height ratio. |
coverPosition | CardCoverPosition | 'top' | Cover placement. |
shadow | CardShadow | 'never' | Card shadow: always or never. |
bordered | boolean | false | Displays a card outline. |
size | CardSize | 'default' | Named component size or an explicit pixel size. |
clickable | boolean | false | Enables click or keyboard interaction. |
loading | boolean | false | Displays a loading state instead of content. |
Root classes and styles use customClass and customStyle. Numbers representing dimensions use px; durations use ms unless explicitly documented.
Events
| Event | Arguments |
|---|---|
click | (event: unknown) |
Controlled state only changes when the parent accepts its update event. Events with multiple words use kebab-case. Disabled or stale asynchronous actions do not emit a successful state change.
Slots
| Slot | Scope |
|---|---|
cover | — |
header | — |
title | — |
extra | — |
default | — |
footer | — |
actions | — |
Methods
None.
Types
CardShadow、CardSize、CardCoverPosition、CardProps、CardEmits.
Platform notes
Supports H5, WeChat mini-program, App-vue and ordinary Vue 3 Web through shared platform components. Unit tests do not replace device acceptance; verify touch, screen readers, deactivation and native rendering on each target.
Device smoke checklist.