[improvement] Card: add thumb link prop (#706)

This commit is contained in:
neverland 2018-10-08 17:43:43 +08:00 committed by GitHub
parent afeed567d2
commit a8d7d248a1
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 25 additions and 9 deletions

View File

@ -54,6 +54,8 @@
| price | 商品价格 | `String | Number` | - |
| centered | 内容是否垂直居中 | `String` | `false` |
| currency | 货币符号 | `String` | `¥` |
| thumb-link | 点击左侧图片后的跳转链接 | `String` | - |
| link-type | 链接跳转类型,可选值为 `redirectTo` `switchTab` `reLaunch` | `String` | `navigateTo` |
### Slot

View File

@ -3,7 +3,7 @@
.van-card {
color: @text-color;
height: 100px;
font-size: 16px;
font-size: 12px;
background: #fafafa;
position: relative;
box-sizing: border-box;
@ -55,9 +55,8 @@
}
&__desc {
color: @gray-darker;
font-size: 12px;
max-height: 20px;
color: @gray-darker;
}
&__price,
@ -68,13 +67,14 @@
text-align: right;
}
&__price {
font-size: 14px;
}
&__num {
color: @gray-darker;
font-size: 12px;
}
&__tag {
position: absolute;
top: 2px;
left: 0;
}
&__tag {

View File

@ -17,9 +17,23 @@ VantComponent({
title: String,
price: String,
centered: Boolean,
thumbLink: String,
linkType: {
type: String,
value: 'navigateTo'
},
currency: {
type: String,
value: '¥'
}
},
methods: {
onClickThumb() {
const { thumbLink } = this.data;
if (thumbLink) {
wx[this.data.linkType]({ url: thumbLink });
}
}
}
});

View File

@ -1,5 +1,5 @@
<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" />
<slot wx:else name="thumb" />
<van-tag