Commit 4909a4cb25ee62661e38cac38a8c3a388fdabbdf
1 parent
1d0ec362
fix(descriotion): fix type #228
Showing
2 changed files
with
7 additions
and
3 deletions
src/components/Description/src/index.tsx
1 | import type { DescOptions, DescInstance, DescItem } from './types'; | 1 | import type { DescOptions, DescInstance, DescItem } from './types'; |
2 | 2 | ||
3 | import { defineComponent, computed, ref, unref, CSSProperties } from 'vue'; | 3 | import { defineComponent, computed, ref, unref, CSSProperties } from 'vue'; |
4 | +import { get } from 'lodash-es'; | ||
4 | import { Descriptions } from 'ant-design-vue'; | 5 | import { Descriptions } from 'ant-design-vue'; |
5 | import { DescriptionsProps } from 'ant-design-vue/es/descriptions/index'; | 6 | import { DescriptionsProps } from 'ant-design-vue/es/descriptions/index'; |
6 | import { CollapseContainer, CollapseContainerOptions } from '/@/components/Container/index'; | 7 | import { CollapseContainer, CollapseContainerOptions } from '/@/components/Container/index'; |
@@ -91,8 +92,11 @@ export default defineComponent({ | @@ -91,8 +92,11 @@ export default defineComponent({ | ||
91 | return null; | 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 | const width = contentMinWidth; | 101 | const width = contentMinWidth; |
98 | return ( | 102 | return ( |
src/components/Description/src/types.ts
@@ -17,7 +17,7 @@ export interface DescItem { | @@ -17,7 +17,7 @@ export interface DescItem { | ||
17 | // render | 17 | // render |
18 | render?: ( | 18 | render?: ( |
19 | val: string, | 19 | val: string, |
20 | - data: Recordable | 20 | + data: Record<string, any> |
21 | ) => VNode | undefined | JSX.Element | Element | string | number; | 21 | ) => VNode | undefined | JSX.Element | Element | string | number; |
22 | } | 22 | } |
23 | 23 |