mirror of
https://github.com/youzan/vant.git
synced 2025-10-22 11:54:02 +00:00
[new feature] Cell: add label slot (#2956)
This commit is contained in:
@@ -18,6 +18,7 @@ export type CellProps = RouteProps &
|
||||
export type CellSlots = DefaultSlots & {
|
||||
icon?: ScopedSlot;
|
||||
title?: ScopedSlot;
|
||||
label?: ScopedSlot;
|
||||
extra?: ScopedSlot;
|
||||
'right-icon'?: ScopedSlot;
|
||||
};
|
||||
@@ -38,11 +39,18 @@ function Cell(
|
||||
|
||||
const showTitle = slots.title || isDef(title);
|
||||
const showValue = slots.default || isDef(value);
|
||||
const showLabel = slots.label || isDef(label);
|
||||
|
||||
const Label = showLabel && (
|
||||
<div class={[bem('label'), props.labelClass]}>
|
||||
{slots.label ? slots.label() : label}
|
||||
</div>
|
||||
);
|
||||
|
||||
const Title = showTitle && (
|
||||
<div class={[bem('title'), props.titleClass]}>
|
||||
{slots.title ? slots.title() : <span>{title}</span>}
|
||||
{label && <div class={[bem('label'), props.labelClass]}>{label}</div>}
|
||||
{Label}
|
||||
</div>
|
||||
);
|
||||
|
||||
|
Reference in New Issue
Block a user