fix: card empty slot render
parent
7789cb2989
commit
96caaa0769
|
@ -370,6 +370,15 @@ export function filterEmpty(children = []) {
|
||||||
return res.filter(c => !isEmptyElement(c));
|
return res.filter(c => !isEmptyElement(c));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export function filterEmptyWithUndefined(children) {
|
||||||
|
if (children) {
|
||||||
|
const coms = filterEmpty(children);
|
||||||
|
return coms.length ? coms : undefined;
|
||||||
|
} else {
|
||||||
|
return children;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
export function mergeProps() {
|
export function mergeProps() {
|
||||||
const args = [].slice.call(arguments, 0);
|
const args = [].slice.call(arguments, 0);
|
||||||
const props = {};
|
const props = {};
|
||||||
|
|
|
@ -4,7 +4,7 @@ import Tabs from '../tabs';
|
||||||
import Row from '../row';
|
import Row from '../row';
|
||||||
import Col from '../col';
|
import Col from '../col';
|
||||||
import PropTypes from '../_util/vue-types';
|
import PropTypes from '../_util/vue-types';
|
||||||
import { flattenChildren, isEmptyElement } from '../_util/props-util';
|
import { flattenChildren, isEmptyElement, filterEmptyWithUndefined } from '../_util/props-util';
|
||||||
import type { SizeType } from '../config-provider';
|
import type { SizeType } from '../config-provider';
|
||||||
import isPlainObject from 'lodash-es/isPlainObject';
|
import isPlainObject from 'lodash-es/isPlainObject';
|
||||||
import useConfigInject from '../_util/hooks/useConfigInject';
|
import useConfigInject from '../_util/hooks/useConfigInject';
|
||||||
|
@ -88,11 +88,11 @@ const Card = defineComponent({
|
||||||
hoverable,
|
hoverable,
|
||||||
activeTabKey,
|
activeTabKey,
|
||||||
defaultActiveTabKey,
|
defaultActiveTabKey,
|
||||||
tabBarExtraContent = slots.tabBarExtraContent?.(),
|
tabBarExtraContent = filterEmptyWithUndefined(slots.tabBarExtraContent?.()),
|
||||||
title = slots.title?.(),
|
title = filterEmptyWithUndefined(slots.title?.()),
|
||||||
extra = slots.extra?.(),
|
extra = filterEmptyWithUndefined(slots.extra?.()),
|
||||||
actions = slots.actions?.(),
|
actions = filterEmptyWithUndefined(slots.actions?.()),
|
||||||
cover = slots.cover?.(),
|
cover = filterEmptyWithUndefined(slots.cover?.()),
|
||||||
} = props;
|
} = props;
|
||||||
const children = flattenChildren(slots.default?.());
|
const children = flattenChildren(slots.default?.());
|
||||||
const pre = prefixCls.value;
|
const pre = prefixCls.value;
|
||||||
|
|
Loading…
Reference in New Issue