mirror of
https://gitee.com/vant-contrib/vant.git
synced 2025-05-24 15:39:15 +08:00
[improvement] Card: add origin-price prop (#1916)
This commit is contained in:
parent
1be1f1e53a
commit
4465e6f705
@ -280,7 +280,7 @@ module.exports = {
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
path: '/card',
|
path: '/card',
|
||||||
title: 'Card 卡片'
|
title: 'Card 商品卡片'
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
path: '/contact-card',
|
path: '/contact-card',
|
||||||
|
@ -14,6 +14,7 @@
|
|||||||
<van-card
|
<van-card
|
||||||
num="2"
|
num="2"
|
||||||
price="2.00"
|
price="2.00"
|
||||||
|
origin-price="10.00"
|
||||||
:tag="$t('tag')"
|
:tag="$t('tag')"
|
||||||
:desc="$t('desc')"
|
:desc="$t('desc')"
|
||||||
:title="$t('title')"
|
:title="$t('title')"
|
||||||
@ -32,7 +33,7 @@
|
|||||||
export default {
|
export default {
|
||||||
i18n: {
|
i18n: {
|
||||||
'zh-CN': {
|
'zh-CN': {
|
||||||
title: '商品标题'
|
title: '商品标题商品标题商品标题商品标题商品标题商品标题商品标题商品标题商品标题'
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
|
@ -32,6 +32,7 @@ Use `slot` to custom content.
|
|||||||
desc="Description"
|
desc="Description"
|
||||||
price="2.00"
|
price="2.00"
|
||||||
:thumb="imageURL"
|
:thumb="imageURL"
|
||||||
|
origin-price="10.00"
|
||||||
>
|
>
|
||||||
<div slot="footer">
|
<div slot="footer">
|
||||||
<van-button size="mini">Button</van-button>
|
<van-button size="mini">Button</van-button>
|
||||||
@ -48,8 +49,9 @@ Use `slot` to custom content.
|
|||||||
| title | Title | `String` | - |
|
| title | Title | `String` | - |
|
||||||
| desc | Description | `String` | - |
|
| desc | Description | `String` | - |
|
||||||
| tag | Tag | `String` | - |
|
| tag | Tag | `String` | - |
|
||||||
| num | Number of goods | `String | Number` | - |
|
| num | Number | `String | Number` | - |
|
||||||
| price | Price of goods | `String | Number` | - |
|
| price | Price | `String | Number` | - |
|
||||||
|
| origin-price | Origin price | `String | Number` | - |
|
||||||
| centered | Whether content vertical centered | `String` | `false` |
|
| centered | Whether content vertical centered | `String` | `false` |
|
||||||
| currency | Currency symbol | `String` | `¥` |
|
| currency | Currency symbol | `String` | `¥` |
|
||||||
| thumb-link | Thumb link URL | `String` | - |
|
| thumb-link | Thumb link URL | `String` | - |
|
||||||
|
@ -2,7 +2,7 @@
|
|||||||
<div :class="b({ center: centered })">
|
<div :class="b({ center: centered })">
|
||||||
<a :href="thumbLink" :class="b('thumb')">
|
<a :href="thumbLink" :class="b('thumb')">
|
||||||
<slot name="thumb">
|
<slot name="thumb">
|
||||||
<img :src="thumb" :class="b('img')" >
|
<img :src="thumb" :class="b('img')">
|
||||||
</slot>
|
</slot>
|
||||||
<van-tag
|
<van-tag
|
||||||
v-if="tag"
|
v-if="tag"
|
||||||
@ -14,20 +14,21 @@
|
|||||||
</van-tag>
|
</van-tag>
|
||||||
</a>
|
</a>
|
||||||
<div :class="b('content')">
|
<div :class="b('content')">
|
||||||
|
<div :class="b('left')">
|
||||||
<slot name="title">
|
<slot name="title">
|
||||||
<div :class="b('row')" v-if="title || isDef(price)">
|
|
||||||
<div v-if="title" :class="b('title')">{{ title }}</div>
|
<div v-if="title" :class="b('title')">{{ title }}</div>
|
||||||
<div v-if="isDef(price)" :class="b('price')">{{ currency }} {{ price }}</div>
|
|
||||||
</div>
|
|
||||||
</slot>
|
</slot>
|
||||||
<slot name="desc">
|
<slot name="desc">
|
||||||
<div :class="b('row')" v-if="desc || isDef(num)">
|
|
||||||
<div v-if="desc" :class="[b('desc'), 'van-ellipsis']">{{ desc }}</div>
|
<div v-if="desc" :class="[b('desc'), 'van-ellipsis']">{{ desc }}</div>
|
||||||
<div v-if="isDef(num)" :class="b('num')">x {{ num }}</div>
|
|
||||||
</div>
|
|
||||||
</slot>
|
</slot>
|
||||||
<slot name="tags" />
|
<slot name="tags" />
|
||||||
</div>
|
</div>
|
||||||
|
<div :class="b('right')">
|
||||||
|
<div v-if="isDef(price)">{{ currency }} {{ price }}</div>
|
||||||
|
<div v-if="isDef(originPrice)" :class="b('origin-price')">{{ currency }} {{ originPrice }}</div>
|
||||||
|
<div v-if="isDef(num)" :class="b('num')">x {{ num }}</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
<div :class="b('footer')" v-if="$slots.footer">
|
<div :class="b('footer')" v-if="$slots.footer">
|
||||||
<slot name="footer" />
|
<slot name="footer" />
|
||||||
</div>
|
</div>
|
||||||
@ -53,6 +54,7 @@ export default create({
|
|||||||
centered: Boolean,
|
centered: Boolean,
|
||||||
num: [Number, String],
|
num: [Number, String],
|
||||||
price: [Number, String],
|
price: [Number, String],
|
||||||
|
originPrice: [Number, String],
|
||||||
currency: {
|
currency: {
|
||||||
type: String,
|
type: String,
|
||||||
default: '¥'
|
default: '¥'
|
||||||
|
@ -9,12 +9,13 @@ exports[`renders demo correctly 1`] = `
|
|||||||
<!---->
|
<!---->
|
||||||
</a>
|
</a>
|
||||||
<div class="van-card__content">
|
<div class="van-card__content">
|
||||||
<div class="van-card__row">
|
<div class="van-card__left">
|
||||||
<div class="van-card__title">商品标题</div>
|
<div class="van-card__title">商品标题商品标题商品标题商品标题商品标题商品标题商品标题商品标题商品标题</div>
|
||||||
<div class="van-card__price">¥ 2.00</div>
|
|
||||||
</div>
|
|
||||||
<div class="van-card__row">
|
|
||||||
<div class="van-card__desc van-ellipsis">描述信息</div>
|
<div class="van-card__desc van-ellipsis">描述信息</div>
|
||||||
|
</div>
|
||||||
|
<div class="van-card__right">
|
||||||
|
<div>¥ 2.00</div>
|
||||||
|
<!---->
|
||||||
<div class="van-card__num">x 2</div>
|
<div class="van-card__num">x 2</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
@ -28,12 +29,13 @@ exports[`renders demo correctly 1`] = `
|
|||||||
标签
|
标签
|
||||||
</span></a>
|
</span></a>
|
||||||
<div class="van-card__content">
|
<div class="van-card__content">
|
||||||
<div class="van-card__row">
|
<div class="van-card__left">
|
||||||
<div class="van-card__title">商品标题</div>
|
<div class="van-card__title">商品标题商品标题商品标题商品标题商品标题商品标题商品标题商品标题商品标题</div>
|
||||||
<div class="van-card__price">¥ 2.00</div>
|
|
||||||
</div>
|
|
||||||
<div class="van-card__row">
|
|
||||||
<div class="van-card__desc van-ellipsis">描述信息</div>
|
<div class="van-card__desc van-ellipsis">描述信息</div>
|
||||||
|
</div>
|
||||||
|
<div class="van-card__right">
|
||||||
|
<div>¥ 2.00</div>
|
||||||
|
<div class="van-card__origin-price">¥ 10.00</div>
|
||||||
<div class="van-card__num">x 2</div>
|
<div class="van-card__num">x 2</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
@ -32,6 +32,7 @@ Vue.use(Card);
|
|||||||
desc="描述信息"
|
desc="描述信息"
|
||||||
title="商品标题"
|
title="商品标题"
|
||||||
:thumb="imageURL"
|
:thumb="imageURL"
|
||||||
|
origin-price="10.00"
|
||||||
>
|
>
|
||||||
<div slot="footer">
|
<div slot="footer">
|
||||||
<van-button size="mini">按钮</van-button>
|
<van-button size="mini">按钮</van-button>
|
||||||
@ -50,6 +51,7 @@ Vue.use(Card);
|
|||||||
| tag | 标签 | `String` | - |
|
| tag | 标签 | `String` | - |
|
||||||
| num | 商品数量 | `String | Number` | - |
|
| num | 商品数量 | `String | Number` | - |
|
||||||
| price | 商品价格 | `String | Number` | - |
|
| price | 商品价格 | `String | Number` | - |
|
||||||
|
| origin-price | 商品划线原价 | `String | Number` | - |
|
||||||
| centered | 内容是否垂直居中 | `String` | `false` |
|
| centered | 内容是否垂直居中 | `String` | `false` |
|
||||||
| currency | 货币符号 | `String` | `¥` |
|
| currency | 货币符号 | `String` | `¥` |
|
||||||
| thumb-link | 点击左侧图片后的跳转链接 | `String` | - |
|
| thumb-link | 点击左侧图片后的跳转链接 | `String` | - |
|
||||||
@ -60,9 +62,9 @@ Vue.use(Card);
|
|||||||
|-----------|-----------|
|
|-----------|-----------|
|
||||||
| title | 自定义标题 |
|
| title | 自定义标题 |
|
||||||
| desc | 自定义描述 |
|
| desc | 自定义描述 |
|
||||||
| tags | 自定义 tags |
|
| tags | 自定义描述下方的内容 |
|
||||||
| thumb | 自定义 thumb |
|
| thumb | 自定义图片 |
|
||||||
| footer | 自定义 footer |
|
| footer | 自定义右下角内容 |
|
||||||
|
|
||||||
### 更新日志
|
### 更新日志
|
||||||
|
|
||||||
|
@ -36,7 +36,8 @@
|
|||||||
|
|
||||||
&,
|
&,
|
||||||
&__thumb,
|
&__thumb,
|
||||||
&__row {
|
&__row,
|
||||||
|
&__content {
|
||||||
display: flex;
|
display: flex;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -66,14 +67,22 @@
|
|||||||
max-height: 20px;
|
max-height: 20px;
|
||||||
}
|
}
|
||||||
|
|
||||||
&__price,
|
&__left {
|
||||||
&__num {
|
|
||||||
flex: 1;
|
flex: 1;
|
||||||
min-width: 80px;
|
}
|
||||||
|
|
||||||
|
&__right {
|
||||||
|
flex-shrink: 0;
|
||||||
line-height: 20px;
|
line-height: 20px;
|
||||||
|
padding-left: 10px;
|
||||||
text-align: right;
|
text-align: right;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
&__origin-price {
|
||||||
|
color: $gray-darker;
|
||||||
|
text-decoration: line-through;
|
||||||
|
}
|
||||||
|
|
||||||
&__num {
|
&__num {
|
||||||
color: $gray-darker;
|
color: $gray-darker;
|
||||||
}
|
}
|
||||||
@ -86,7 +95,7 @@
|
|||||||
|
|
||||||
&__footer {
|
&__footer {
|
||||||
right: 15px;
|
right: 15px;
|
||||||
bottom: 5px;
|
bottom: 8px;
|
||||||
position: absolute;
|
position: absolute;
|
||||||
|
|
||||||
.van-button {
|
.van-button {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user