要在 Office UI Fabric DetailsRow 中包装文本,你可以使用 DetailsRow 的 onRenderItemColumn 属性来自定义要显示的内容。以下是一个示例代码,展示如何包装 Office UI Fabric DetailsRow 的文本:
import * as React from 'react';
import { DetailsList, DetailsRow, IColumn, IDetailsRowProps } from 'office-ui-fabric-react/lib/DetailsList';
const columns: IColumn[] = [
{ key: 'column1', name: 'Column 1', fieldName: 'column1', minWidth: 100, maxWidth: 200, isResizable: true },
{ key: 'column2', name: 'Column 2', fieldName: 'column2', minWidth: 100, maxWidth: 200, isResizable: true },
{ key: 'column3', name: 'Column 3', fieldName: 'column3', minWidth: 100, maxWidth: 200, isResizable: true }
];
const items = [
{ column1: 'Item 1', column2: 'Value 1', column3: 'Description 1' },
{ column1: 'Item 2', column2: 'Value 2', column3: 'Description 2' },
{ column1: 'Item 3', column2: 'Value 3', column3: 'Description 3' }
];
const renderTextContent = (props: IDetailsRowProps, defaultRender?: (props?: IDetailsRowProps) => JSX.Element | null) => {
const text = props.item[props.columnKey as keyof typeof props.item] as string;
return {text};
};
const DetailsListExample: React.FunctionComponent = () => {
return (
}
/>
);
};
export default DetailsListExample;
在这个示例中,我们定义了一个 DetailsList,其中包含了三列:Column 1,Column 2和Column 3。我们通过 onRenderRow 属性来自定义 DetailsRow 的渲染,使用 onRenderItemColumn 属性来自定义每列的内容。在 renderTextContent 函数中,我们将每列的文本包装在一个 元素中,并设置了 fontWeight 的样式。
你可以根据自己的需求调整代码中的样式和自定义内容。
上一篇:包中缺少数据集
下一篇:包装操作是否会构建项目?