Commit 4909a4cb25ee62661e38cac38a8c3a388fdabbdf

Authored by vben
1 parent 1d0ec362

fix(descriotion): fix type #228

src/components/Description/src/index.tsx
1 1 import type { DescOptions, DescInstance, DescItem } from './types';
2 2  
3 3 import { defineComponent, computed, ref, unref, CSSProperties } from 'vue';
  4 +import { get } from 'lodash-es';
4 5 import { Descriptions } from 'ant-design-vue';
5 6 import { DescriptionsProps } from 'ant-design-vue/es/descriptions/index';
6 7 import { CollapseContainer, CollapseContainerOptions } from '/@/components/Container/index';
... ... @@ -91,8 +92,11 @@ export default defineComponent({
91 92 return null;
92 93 }
93 94  
94   - const getContent = () =>
95   - isFunction(render) ? render(data?.[field], data) : unref(data) && unref(data)[field];
  95 + const getContent = () => {
  96 + const _data = unref(data);
  97 + const getField = get(_data, field);
  98 + return isFunction(render) ? render(getField, _data) : getField ?? '';
  99 + };
96 100  
97 101 const width = contentMinWidth;
98 102 return (
... ...
src/components/Description/src/types.ts
... ... @@ -17,7 +17,7 @@ export interface DescItem {
17 17 // render
18 18 render?: (
19 19 val: string,
20   - data: Recordable
  20 + data: Record<string, any>
21 21 ) => VNode | undefined | JSX.Element | Element | string | number;
22 22 }
23 23  
... ...