From 0f11e4ecd42a658fd1756f52445260acb2bcc83b Mon Sep 17 00:00:00 2001 From: tangjinzhou <415800467@qq.com> Date: Thu, 1 Sep 2022 16:11:01 +0800 Subject: [PATCH] fix: descriptionsItem labelStyle not work, close #5920 --- components/descriptions/Row.tsx | 33 ++++++++++++++++----------------- 1 file changed, 16 insertions(+), 17 deletions(-) diff --git a/components/descriptions/Row.tsx b/components/descriptions/Row.tsx index 0f0e7055c..a2c1820a5 100644 --- a/components/descriptions/Row.tsx +++ b/components/descriptions/Row.tsx @@ -1,8 +1,7 @@ import Cell from './Cell'; import { getSlot, getClass, getStyle } from '../_util/props-util'; -import type { FunctionalComponent, VNode } from 'vue'; +import type { CSSProperties, FunctionalComponent, VNode } from 'vue'; import { inject, ref } from 'vue'; -import type { DescriptionsContextProp } from './index'; import { descriptionsContext } from './index'; interface CellConfig { @@ -32,29 +31,29 @@ const Row: FunctionalComponent = props => { showContent, labelStyle: rootLabelStyle, contentStyle: rootContentStyle, - }: CellConfig & DescriptionsContextProp, + }: CellConfig & { labelStyle?: CSSProperties; contentStyle?: CSSProperties }, ) => { return items.map((item, index) => { + const itemProps = item.props || {}; const { prefixCls: itemPrefixCls = prefixCls, span = 1, - labelStyle, - contentStyle, + labelStyle = itemProps['label-style'], + contentStyle = itemProps['content-style'], label = (item.children as any)?.label?.(), - } = item.props || {}; + } = itemProps; const children = getSlot(item); const className = getClass(item); const style = getStyle(item); const { key } = item; - if (typeof component === 'string') { return ( = props => { = props => { = props => { component: 'th', type: 'label', showLabel: true, - labelStyle, - contentStyle, + labelStyle: labelStyle.value, + contentStyle: contentStyle.value, })} @@ -114,8 +113,8 @@ const Row: FunctionalComponent = props => { component: 'td', type: 'content', showContent: true, - labelStyle, - contentStyle, + labelStyle: labelStyle.value, + contentStyle: contentStyle.value, })} @@ -129,8 +128,8 @@ const Row: FunctionalComponent = props => { type: 'item', showLabel: true, showContent: true, - labelStyle, - contentStyle, + labelStyle: labelStyle.value, + contentStyle: contentStyle.value, })} );