Skip to content

Commit

Permalink
fix(descriotion): fix type #228
Browse files Browse the repository at this point in the history
  • Loading branch information
anncwb committed Feb 3, 2021
1 parent 1d0ec36 commit 4909a4c
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 3 deletions.
8 changes: 6 additions & 2 deletions src/components/Description/src/index.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import type { DescOptions, DescInstance, DescItem } from './types';

import { defineComponent, computed, ref, unref, CSSProperties } from 'vue';
import { get } from 'lodash-es';
import { Descriptions } from 'ant-design-vue';
import { DescriptionsProps } from 'ant-design-vue/es/descriptions/index';
import { CollapseContainer, CollapseContainerOptions } from '/@/components/Container/index';
Expand Down Expand Up @@ -91,8 +92,11 @@ export default defineComponent({
return null;
}

const getContent = () =>
isFunction(render) ? render(data?.[field], data) : unref(data) && unref(data)[field];
const getContent = () => {
const _data = unref(data);
const getField = get(_data, field);
return isFunction(render) ? render(getField, _data) : getField ?? '';
};

const width = contentMinWidth;
return (
Expand Down
2 changes: 1 addition & 1 deletion src/components/Description/src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ export interface DescItem {
// render
render?: (
val: string,

This comment has been minimized.

Copy link
@JohnNiang

JohnNiang Feb 4, 2021

应该是 val 的类型为 any 吧,data 的类型可以是 Recordable,它本身就是 Record<string, any>。

data: Recordable
data: Record<string, any>
) => VNode | undefined | JSX.Element | Element | string | number;
}

Expand Down

0 comments on commit 4909a4c

Please sign in to comment.