import{o as s,a,y as n}from"./vue-libs.b44bc779.js";const d={class:"van-doc-markdown-body"},e=n(`
Used to display product pictures, prices and other information.
Register component globally via app.use
, refer to Component Registration for more registration ways.
import { createApp } from 'vue';
import { Card } from 'vant';
const app = createApp();
app.use(Card);
<van-card
num="2"
price="2.00"
title="Title"
desc="Description"
thumb="https://fastly.jsdelivr.net/npm/@vant/assets/ipad.jpeg"
/>
<van-card
num="2"
tag="Tag"
price="2.00"
title="Title"
desc="Description"
origin-price="10.00"
thumb="https://fastly.jsdelivr.net/npm/@vant/assets/ipad.jpeg"
/>
Use slot to custom content.
<van-card
num="2"
title="Title"
desc="Description"
price="2.00"
thumb="https://fastly.jsdelivr.net/npm/@vant/assets/ipad.jpeg"
>
<template #tags>
<van-tag plain type="danger">Tag</van-tag>
<van-tag plain type="danger">Tag</van-tag>
</template>
<template #footer>
<van-button size="mini">Button</van-button>
<van-button size="mini">Button</van-button>
</template>
</van-card>
Attribute | Description | Type | Default |
---|---|---|---|
thumb | Left thumb image URL | string | - |
title | Title | string | - |
desc | Description | string | - |
tag | Tag | string | - |
num | number | number | string | - |
price | Price | number | string | - |
origin-price | Origin price | number | string | - |
centered | Whether content vertical centered | boolean | false |
currency | Currency symbol | string | \xA5 |
thumb-link | Thumb link URL | string | - |
lazy-load | Whether to enable thumb lazy load, should register Lazyload component | boolean | false |
Event | Description | Arguments |
---|---|---|
click | Emitted when component is clicked | event: MouseEvent |
click-thumb | Emitted when thumb is clicked | event: MouseEvent |
Name | Description |
---|---|
title | Custom title |
desc | Custom description |
num | Custom num |
price | Custom price |
origin-price | Custom origin price |
price-top | Custom price top |
bottom | Custom price bottom |
thumb | Custom thumb |
tag | Custom thumb tag |
tags | Custom tags |
footer | Custom footer |
The component exports the following type definitions:
import type { CardProps } from 'vant';
The component provides the following CSS variables, which can be used to customize styles. Please refer to ConfigProvider component.
Name | Default Value | Description |
---|---|---|
--van-card-padding | var(--van-padding-xs) var(--van-padding-md) | - |
--van-card-font-size | var(--van-font-size-sm) | - |
--van-card-text-color | var(--van-text-color) | - |
--van-card-background-color | var(--van-gray-1) | - |
--van-card-thumb-size | 88px | - |
--van-card-thumb-border-radius | var(--van-border-radius-lg) | - |
--van-card-title-line-height | 16px | - |
--van-card-desc-color | var(--van-gray-7) | - |
--van-card-desc-line-height | var(--van-line-height-md) | - |
--van-card-price-color | var(--van-gray-8) | - |
--van-card-origin-price-color | var(--van-text-color-2) | - |
--van-card-num-color | var(--van-text-color-2) | - |
--van-card-origin-price-font-size | var(--van-font-size-xs) | - |
--van-card-price-font-size | var(--van-font-size-sm) | - |
--van-card-price-integer-font-size | var(--van-font-size-lg) | - |
--van-card-price-font-family | var(--van-price-integer-font-family) | - |