Skip to content

Commit

Permalink
feat(Card): add slots attrs (#2787)
Browse files Browse the repository at this point in the history
  • Loading branch information
Lindysen authored Feb 26, 2020
1 parent e3941c7 commit a63d565
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 2 deletions.
2 changes: 2 additions & 0 deletions packages/card/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,8 @@
| title | 自定义标题栏,如果设置了`title`属性则不生效 |
| desc | 自定义描述栏,如果设置了`desc`属性则不生效 |
| price-top | 自定义价格上方区域 |
| price | 自定义价格 |
| num | 自定义数量 |
| thumb | 自定义 thumb,如果设置了`thumb`属性则不生效 |
| bottom | 自定义价格下方区域 |
| footer | 自定义 footer |
Expand Down
4 changes: 2 additions & 2 deletions packages/card/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ VantComponent({
'thumb-class',
'title-class',
'price-class',
'origin-price-class',
'origin-price-class'
],

mixins: [link],
Expand Down Expand Up @@ -43,7 +43,7 @@ VantComponent({
const priceArr = price.toString().split('.');
this.setData({
integerStr: priceArr[0],
decimalStr: priceArr[1] ? `.${priceArr[1]}` : '',
decimalStr: priceArr[1] ? `.${priceArr[1]}` : ''
});
},

Expand Down
2 changes: 2 additions & 0 deletions packages/card/index.wxml
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,10 @@
<view class="van-card__bottom">
<slot name="price-top" />
<view wx:if="{{ price || price === 0 }}" class="van-card__price price-class">{{ currency }}<text class="van-card__price-integer">{{ integerStr }}</text><text class="van-card__price-decimal">{{ decimalStr }}</text></view>
<slot wx:else name="price" />
<view wx:if="{{ originPrice || originPrice === 0 }}" class="van-card__origin-price origin-price-class">{{ currency }} {{ originPrice }}</view>
<view wx:if="{{ num }}" class="van-card__num num-class">x {{ num }}</view>
<slot wx:else name="num" />
<slot name="bottom" />
</view>
</view>
Expand Down

0 comments on commit a63d565

Please sign in to comment.