feat(Cell): add value slot, deprecate default slot (#8933)

This commit is contained in:
neverland
2021-06-26 21:31:46 +08:00
committed by GitHub
parent 8354877428
commit 29f800b827
5 changed files with 41 additions and 21 deletions
+6 -3
View File
@@ -33,7 +33,7 @@ export const cellProps = {
valueClass: unknownProp,
labelClass: unknownProp,
titleClass: unknownProp,
titleStyle: (null as unknown) as PropType<string | CSSProperties>,
titleStyle: null as unknown as PropType<string | CSSProperties>,
arrowDirection: String as PropType<CellArrowDirection>,
clickable: {
type: Boolean as PropType<boolean | null>,
@@ -76,13 +76,16 @@ export default defineComponent({
};
const renderValue = () => {
const hasValue = slots.default || isDef(props.value);
// default slot is deprecated
// should be removed in next major version
const slot = slots.value || slots.default;
const hasValue = slot || isDef(props.value);
if (hasValue) {
const hasTitle = slots.title || isDef(props.title);
return (
<div class={[bem('value', { alone: !hasTitle }), props.valueClass]}>
{slots.default ? slots.default() : <span>{props.value}</span>}
{slot ? slot() : <span>{props.value}</span>}
</div>
);
}