feat(Card): Card 组件样式调整添加 price 上方的插槽 (#5134)
This commit is contained in:
+20
-5
@@ -32,6 +32,7 @@ export type CardSlots = DefaultSlots & {
|
||||
bottom?: ScopedSlot;
|
||||
footer?: ScopedSlot;
|
||||
'origin-price'?: ScopedSlot;
|
||||
'price-top'?: ScopedSlot;
|
||||
};
|
||||
|
||||
export type CardEvents = {
|
||||
@@ -114,11 +115,22 @@ function Card(
|
||||
}
|
||||
}
|
||||
|
||||
function PriceContent() {
|
||||
const priceArr = props.price!.toString().split('.');
|
||||
return (
|
||||
<div>
|
||||
{props.currency}
|
||||
<span class={bem('price', 'integer')}>{priceArr[0]}</span>.
|
||||
{priceArr[1]}
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
function Price() {
|
||||
if (showPrice) {
|
||||
return (
|
||||
<div class={bem('price')}>
|
||||
{slots.price ? slots.price() : `${props.currency} ${props.price}`}
|
||||
{slots.price ? slots.price() : PriceContent()}
|
||||
</div>
|
||||
);
|
||||
}
|
||||
@@ -137,7 +149,7 @@ function Card(
|
||||
|
||||
function Num() {
|
||||
if (showNum) {
|
||||
return <div class={bem('num')}>{slots.num ? slots.num() : `x ${props.num}`}</div>;
|
||||
return <div class={bem('num')}>{slots.num ? slots.num() : `x${props.num}`}</div>;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -152,11 +164,14 @@ function Card(
|
||||
<div class={bem('header')}>
|
||||
{Thumb()}
|
||||
<div class={bem('content', { centered: props.centered })}>
|
||||
{Title()}
|
||||
{Desc()}
|
||||
{slots.tags && slots.tags()}
|
||||
<div>
|
||||
{Title()}
|
||||
{Desc()}
|
||||
{slots.tags && slots.tags()}
|
||||
</div>
|
||||
{showBottom && (
|
||||
<div class="van-card__bottom">
|
||||
{slots['price-top'] && slots['price-top']()}
|
||||
{Price()}
|
||||
{OriginPrice()}
|
||||
{Num()}
|
||||
|
||||
Reference in New Issue
Block a user