提交 4909a4cb 作者: vben

fix(descriotion): fix type #228

上级 1d0ec362
import type { DescOptions, DescInstance, DescItem } from './types'; import type { DescOptions, DescInstance, DescItem } from './types';
import { defineComponent, computed, ref, unref, CSSProperties } from 'vue'; import { defineComponent, computed, ref, unref, CSSProperties } from 'vue';
import { get } from 'lodash-es';
import { Descriptions } from 'ant-design-vue'; import { Descriptions } from 'ant-design-vue';
import { DescriptionsProps } from 'ant-design-vue/es/descriptions/index'; import { DescriptionsProps } from 'ant-design-vue/es/descriptions/index';
import { CollapseContainer, CollapseContainerOptions } from '/@/components/Container/index'; import { CollapseContainer, CollapseContainerOptions } from '/@/components/Container/index';
...@@ -91,8 +92,11 @@ export default defineComponent({ ...@@ -91,8 +92,11 @@ export default defineComponent({
return null; return null;
} }
const getContent = () => const getContent = () => {
isFunction(render) ? render(data?.[field], data) : unref(data) && unref(data)[field]; const _data = unref(data);
const getField = get(_data, field);
return isFunction(render) ? render(getField, _data) : getField ?? '';
};
const width = contentMinWidth; const width = contentMinWidth;
return ( return (
......
...@@ -17,7 +17,7 @@ export interface DescItem { ...@@ -17,7 +17,7 @@ export interface DescItem {
// render // render
render?: ( render?: (
val: string, val: string,
data: Recordable data: Record<string, any>
) => VNode | undefined | JSX.Element | Element | string | number; ) => VNode | undefined | JSX.Element | Element | string | number;
} }
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论