浏览代码

fix(card): add price slot (#1452)

zjyau 3 年之前
父节点
当前提交
7fb28bc3d8

+ 3 - 0
src/packages/__VUE/card/demo.vue

@@ -42,6 +42,9 @@
       <template #shop-tag>
         <div>{{ translate('customShop') }}</div>
       </template>
+      <template #price>
+        <span>询价</span>
+      </template>
       <template #origin>
         <img
           class="tag"

+ 1 - 0
src/packages/__VUE/card/doc.en-US.md

@@ -163,6 +163,7 @@ app.use(Card).use(Tag).use(Price);
 | Name    | Description         |
 |---------|--------------|
 | prolist | 	Custom product introduction |
+| price | 	Custom price |
 | origin | 	Custom content behind the price |
 | shop-tag | 	Custom shop introduction |
 | footer | 	Customize bottom right content |

+ 1 - 0
src/packages/__VUE/card/doc.md

@@ -163,6 +163,7 @@ app.use(Card).use(Tag).use(Price);
 | 名称    | 说明         |
 |---------|--------------|
 | prolist | 	自定义商品介绍 |
+| price | 	价格自定义内容 |
 | origin | 	价格后方自定义内容 |
 | shop-tag | 	店铺介绍自定义 |
 | footer | 	右下角内容自定义 |

+ 4 - 1
src/packages/__VUE/card/index.taro.vue

@@ -7,7 +7,10 @@
       <div class="nut-card__right__title">{{ title }}</div>
       <slot name="prolist"></slot>
       <div class="nut-card__right__price" v-if="isNeedPrice">
-        <nut-price :price="price"></nut-price>
+        <template v-if="isHaveSlot('price')">
+          <slot name="price"></slot>
+        </template>
+        <nut-pric v-else :price="price"></nut-pric>
         <template v-if="isHaveSlot('origin')">
           <slot name="origin"></slot>
         </template>

+ 4 - 1
src/packages/__VUE/card/index.vue

@@ -7,7 +7,10 @@
       <div class="nut-card__right__title">{{ title }}</div>
       <slot name="prolist"></slot>
       <div class="nut-card__right__price" v-if="isNeedPrice">
-        <nut-price :price="price"></nut-price>
+        <template v-if="isHaveSlot('price')">
+          <slot name="price"></slot>
+        </template>
+        <nut-price v-else :price="price"></nut-price>
         <template v-if="isHaveSlot('origin')">
           <slot name="origin"></slot>
         </template>

+ 2 - 1
src/packages/__VUE/card/test/index.spec.ts

@@ -47,10 +47,11 @@ test('normal props', () => {
   expect(wrapper.html()).toMatchSnapshot();
 });
 
-test('render prolist and origin slot correctly', () => {
+test('render prolist , price and origin slot correctly', () => {
   const wrapper = mount(Card, {
     slots: {
       prolist: () => 'Custom prolist',
+      price: () => 'Custom price',
       origin: () => 'Custom origin'
     }
   });