From e2d9b12bd2a097ed45134f549ac0cd6994277fd9 Mon Sep 17 00:00:00 2001 From: chenjiahan Date: Tue, 18 Aug 2020 17:09:46 +0800 Subject: [PATCH] feat: migrate GoodsAction component --- components.js | 3 +++ src/goods-action-button/index.js | 4 +++- src/goods-action-icon/index.js | 9 +++++---- src/goods-action/index.js | 2 +- vant.config.js | 16 ++++++++-------- 5 files changed, 20 insertions(+), 14 deletions(-) diff --git a/components.js b/components.js index 7eb55865c..e061b9047 100644 --- a/components.js +++ b/components.js @@ -77,4 +77,7 @@ module.exports = [ 'coupon-list', 'coupon-cell', 'submit-bar', + 'goods-action', + 'goods-action-icon', + 'goods-action-button', ]; diff --git a/src/goods-action-button/index.js b/src/goods-action-button/index.js index 39f8e974e..fbb3d63d6 100644 --- a/src/goods-action-button/index.js +++ b/src/goods-action-button/index.js @@ -18,6 +18,8 @@ export default createComponent({ disabled: Boolean, }, + emits: ['click'], + computed: { isFirst() { const prev = this.parent && this.parent.children[this.index - 1]; @@ -55,7 +57,7 @@ export default createComponent({ disabled={this.disabled} onClick={this.onClick} > - {this.slots() || this.text} + {this.$slots.default ? this.$slots.default() : this.text} ); }, diff --git a/src/goods-action-icon/index.js b/src/goods-action-icon/index.js index b9bb118dc..dff2835e0 100644 --- a/src/goods-action-icon/index.js +++ b/src/goods-action-icon/index.js @@ -20,6 +20,8 @@ export default createComponent({ iconClass: null, }, + emits: ['click'], + methods: { onClick(event) { this.$emit('click', event); @@ -27,13 +29,12 @@ export default createComponent({ }, genIcon() { - const slot = this.slots('icon'); const info = isDef(this.badge) ? this.badge : this.info; - if (slot) { + if (this.$slots.icon) { return (
- {slot} + {this.$slots.icon()}
); @@ -56,7 +57,7 @@ export default createComponent({ return (
{this.genIcon()} - {this.slots() || this.text} + {this.$slots.default ? this.$slots.default() : this.text}
); }, diff --git a/src/goods-action/index.js b/src/goods-action/index.js index a5ec63f97..aeca65893 100644 --- a/src/goods-action/index.js +++ b/src/goods-action/index.js @@ -16,7 +16,7 @@ export default createComponent({ render() { return (
- {this.slots()} + {this.$slots.default?.()}
); }, diff --git a/vant.config.js b/vant.config.js index 735c200f6..1ac16e342 100644 --- a/vant.config.js +++ b/vant.config.js @@ -347,10 +347,10 @@ module.exports = { path: 'coupon-list', title: 'Coupon 优惠券', }, - // { - // path: 'goods-action', - // title: 'GoodsAction 商品导航', - // }, + { + path: 'goods-action', + title: 'GoodsAction 商品导航', + }, { path: 'submit-bar', title: 'SubmitBar 提交订单栏', @@ -681,10 +681,10 @@ module.exports = { path: 'coupon-list', title: 'Coupon', }, - // { - // path: 'goods-action', - // title: 'GoodsAction', - // }, + { + path: 'goods-action', + title: 'GoodsAction', + }, { path: 'submit-bar', title: 'SubmitBar',