From 86fe2fd2848e2c299397aaa2ceeeaf0500bc43cf Mon Sep 17 00:00:00 2001 From: zanyuki-jd Date: Thu, 25 Jul 2024 18:29:25 +0800 Subject: [PATCH] refactor: table (#2473) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * feat(table): table新增自定义行 * feat(table): 解决文件导入问题 * refactor(table): cr调整 * refactor(table): cr调整 * refactor(table): 自定义行逻辑调整 --------- Co-authored-by: qinliuxiao1 --- src/packages/table/demos/h5/demo14.tsx | 30 +++++++++++++----------- src/packages/table/demos/taro/demo14.tsx | 30 +++++++++++++----------- src/packages/table/table.taro.tsx | 11 +++++---- src/packages/table/table.tsx | 11 +++++---- 4 files changed, 44 insertions(+), 38 deletions(-) diff --git a/src/packages/table/demos/h5/demo14.tsx b/src/packages/table/demos/h5/demo14.tsx index 1bcfcdaffb..b1c28a6140 100644 --- a/src/packages/table/demos/h5/demo14.tsx +++ b/src/packages/table/demos/h5/demo14.tsx @@ -29,20 +29,22 @@ const Demo14 = () => { text: '这里是自定义行', Component: (props: any) => { return ( -
-
- {props.text} +
+
+
+ {props.text} +
) diff --git a/src/packages/table/demos/taro/demo14.tsx b/src/packages/table/demos/taro/demo14.tsx index 94d50a8cbf..722976adc1 100644 --- a/src/packages/table/demos/taro/demo14.tsx +++ b/src/packages/table/demos/taro/demo14.tsx @@ -29,20 +29,22 @@ const Demo14 = () => { text: '这里是自定义行', Component: (props: any) => { return ( -
-
- {props.text} +
+
+
+ {props.text} +
) diff --git a/src/packages/table/table.taro.tsx b/src/packages/table/table.taro.tsx index 22d55d9add..5bce1bf686 100644 --- a/src/packages/table/table.taro.tsx +++ b/src/packages/table/table.taro.tsx @@ -125,10 +125,6 @@ export const Table: FunctionComponent< } const renderBodyTds = (item: any, rowIndex: number) => { - const { rowRender } = item - if (rowRender && typeof rowRender === 'function') { - return rowRender(item, rowIndex) - } return sortDataItem().map(([value, render]) => { return (
{ return innerValue.map((item, index) => { + const inner = renderBodyTds(item, index) + const { rowRender } = item + if (rowRender && typeof rowRender === 'function') { + return rowRender(item, index, { inner }) + } return (
- {renderBodyTds(item, index)} + {inner}
) }) diff --git a/src/packages/table/table.tsx b/src/packages/table/table.tsx index 5cdc538924..18ba2c7bbf 100644 --- a/src/packages/table/table.tsx +++ b/src/packages/table/table.tsx @@ -122,10 +122,6 @@ export const Table: FunctionComponent< } const renderBodyTds = (item: any, rowIndex: number) => { - const { rowRender } = item - if (rowRender && typeof rowRender === 'function') { - return rowRender(item, rowIndex) - } return sortDataItem().map(([value, render]) => { return (
{ return innerValue.map((item, index) => { + const inner = renderBodyTds(item, index) + const { rowRender } = item + if (rowRender && typeof rowRender === 'function') { + return rowRender(item, index, { inner }) + } return (
- {renderBodyTds(item, index)} + {inner}
) })