From 820df7743301ee936a7cba7dd61d1b66e5b56e19 Mon Sep 17 00:00:00 2001 From: 2betop <2betop.cn@gmail.com> Date: Wed, 12 Jul 2023 21:12:27 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E4=BF=AE=E5=A4=8D=E8=B6=85=E7=BA=A7?= =?UTF-8?q?=E8=A1=A8=E5=A4=B4=E5=88=97=E5=9B=BA=E5=AE=9A=E4=BD=8D=E7=BD=AE?= =?UTF-8?q?=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- packages/amis/src/renderers/Table/index.tsx | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/packages/amis/src/renderers/Table/index.tsx b/packages/amis/src/renderers/Table/index.tsx index 17b5383fe..298f9e4ed 100644 --- a/packages/amis/src/renderers/Table/index.tsx +++ b/packages/amis/src/renderers/Table/index.tsx @@ -1129,9 +1129,18 @@ export default class Table extends React.Component { // 自动将 table-layout: auto 改成 fixed if (!store.columnWidthReady) { const cx = this.props.classnames; - const ths: HTMLTableCellElement[] = [].slice.call( - table.querySelectorAll('thead>tr:last-child>th[data-index]') - ); + const ths = ( + [].slice.call( + table.querySelectorAll('thead>tr>th[data-index]') + ) as HTMLTableCellElement[] + ).filter((th, index, arr) => { + return ( + arr.findIndex( + item => + item.getAttribute('data-index') === th.getAttribute('data-index') + ) === index + ); + }); const div = document.createElement('div'); div.className = 'amis-scope'; // jssdk 里面 css 会在这一层