mirror of
https://github.com/youzan/vant.git
synced 2025-10-21 19:24:16 +00:00
[improvement] Sku: partial functional (#2756)
This commit is contained in:
@@ -1,32 +1,33 @@
|
||||
import { use } from '../../utils';
|
||||
import { inherit } from '../../utils/functional';
|
||||
import Button from '../../button';
|
||||
|
||||
const [sfc, bem] = use('sku-actions');
|
||||
|
||||
export default sfc({
|
||||
props: {
|
||||
buyText: String,
|
||||
skuEventBus: Object,
|
||||
showAddCartBtn: Boolean
|
||||
},
|
||||
function SkuActions(h, props, slots, ctx) {
|
||||
const emit = name => () => {
|
||||
props.skuEventBus.$emit(name);
|
||||
};
|
||||
|
||||
render(h) {
|
||||
const emit = name => () => {
|
||||
this.skuEventBus.$emit(name);
|
||||
};
|
||||
return (
|
||||
<div class={bem()} {...inherit(ctx)}>
|
||||
{props.showAddCartBtn && (
|
||||
<Button bottomAction text="加入购物车" onClick={emit('sku:addCart')} />
|
||||
)}
|
||||
<Button
|
||||
type="primary"
|
||||
bottomAction
|
||||
text={props.buyText || '立即购买'}
|
||||
onClick={emit('sku:buy')}
|
||||
/>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
return (
|
||||
<div class={bem()}>
|
||||
{this.showAddCartBtn && (
|
||||
<Button bottomAction text="加入购物车" onClick={emit('sku:addCart')} />
|
||||
)}
|
||||
<Button
|
||||
type="primary"
|
||||
bottomAction
|
||||
text={this.buyText || '立即购买'}
|
||||
onClick={emit('sku:buy')}
|
||||
/>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
});
|
||||
SkuActions.props = {
|
||||
buyText: String,
|
||||
skuEventBus: Object,
|
||||
showAddCartBtn: Boolean
|
||||
};
|
||||
|
||||
export default sfc(SkuActions);
|
||||
|
Reference in New Issue
Block a user