mirror of
https://gitee.com/vant-contrib/vant-weapp.git
synced 2025-04-06 03:58:05 +08:00
[improvement] Card: add thumb link prop (#706)
This commit is contained in:
parent
afeed567d2
commit
a8d7d248a1
@ -54,6 +54,8 @@
|
|||||||
| price | 商品价格 | `String | Number` | - |
|
| price | 商品价格 | `String | Number` | - |
|
||||||
| centered | 内容是否垂直居中 | `String` | `false` |
|
| centered | 内容是否垂直居中 | `String` | `false` |
|
||||||
| currency | 货币符号 | `String` | `¥` |
|
| currency | 货币符号 | `String` | `¥` |
|
||||||
|
| thumb-link | 点击左侧图片后的跳转链接 | `String` | - |
|
||||||
|
| link-type | 链接跳转类型,可选值为 `redirectTo` `switchTab` `reLaunch` | `String` | `navigateTo` |
|
||||||
|
|
||||||
### Slot
|
### Slot
|
||||||
|
|
||||||
|
@ -3,7 +3,7 @@
|
|||||||
.van-card {
|
.van-card {
|
||||||
color: @text-color;
|
color: @text-color;
|
||||||
height: 100px;
|
height: 100px;
|
||||||
font-size: 16px;
|
font-size: 12px;
|
||||||
background: #fafafa;
|
background: #fafafa;
|
||||||
position: relative;
|
position: relative;
|
||||||
box-sizing: border-box;
|
box-sizing: border-box;
|
||||||
@ -55,9 +55,8 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
&__desc {
|
&__desc {
|
||||||
color: @gray-darker;
|
|
||||||
font-size: 12px;
|
|
||||||
max-height: 20px;
|
max-height: 20px;
|
||||||
|
color: @gray-darker;
|
||||||
}
|
}
|
||||||
|
|
||||||
&__price,
|
&__price,
|
||||||
@ -68,13 +67,14 @@
|
|||||||
text-align: right;
|
text-align: right;
|
||||||
}
|
}
|
||||||
|
|
||||||
&__price {
|
|
||||||
font-size: 14px;
|
|
||||||
}
|
|
||||||
|
|
||||||
&__num {
|
&__num {
|
||||||
color: @gray-darker;
|
color: @gray-darker;
|
||||||
font-size: 12px;
|
}
|
||||||
|
|
||||||
|
&__tag {
|
||||||
|
position: absolute;
|
||||||
|
top: 2px;
|
||||||
|
left: 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
&__tag {
|
&__tag {
|
||||||
|
@ -17,9 +17,23 @@ VantComponent({
|
|||||||
title: String,
|
title: String,
|
||||||
price: String,
|
price: String,
|
||||||
centered: Boolean,
|
centered: Boolean,
|
||||||
|
thumbLink: String,
|
||||||
|
linkType: {
|
||||||
|
type: String,
|
||||||
|
value: 'navigateTo'
|
||||||
|
},
|
||||||
currency: {
|
currency: {
|
||||||
type: String,
|
type: String,
|
||||||
value: '¥'
|
value: '¥'
|
||||||
}
|
}
|
||||||
|
},
|
||||||
|
|
||||||
|
methods: {
|
||||||
|
onClickThumb() {
|
||||||
|
const { thumbLink } = this.data;
|
||||||
|
if (thumbLink) {
|
||||||
|
wx[this.data.linkType]({ url: thumbLink });
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
<view class="custom-class van-card {{ centered ? 'van-card--center' : '' }}">
|
<view class="custom-class van-card {{ centered ? 'van-card--center' : '' }}">
|
||||||
<view class="van-card__thumb">
|
<view class="van-card__thumb" bind:tap="onClickThumb">
|
||||||
<image wx:if="{{ thumb }}" src="{{ thumb }}" class="van-card__img thumb-class" />
|
<image wx:if="{{ thumb }}" src="{{ thumb }}" class="van-card__img thumb-class" />
|
||||||
<slot wx:else name="thumb" />
|
<slot wx:else name="thumb" />
|
||||||
<van-tag
|
<van-tag
|
||||||
|
Loading…
x
Reference in New Issue
Block a user