Przeglądaj źródła

fix: [BasicTable] 第二次数据加载依旧没有数据时高度计算有误差

lanjianrong 4 lat temu
rodzic
commit
27ce2ee531
1 zmienionych plików z 3 dodań i 2 usunięć
  1. 3 2
      src/components/Table/src/hooks/useTableScroll.ts

+ 3 - 2
src/components/Table/src/hooks/useTableScroll.ts

@@ -68,7 +68,7 @@ export function useTableScroll({
       // TODO: 在已经设置过style的情况下才要取消掉style
       // tableContainerEl!.removeAttribute('style')
       tableContainerEl!.style.borderBottom = 'none'
-      paddingHeight += 16
+      !tableContainerEl!.style.marginBottom && (paddingHeight += 16)
     }
 
     let headerHeight = 0
@@ -82,7 +82,7 @@ export function useTableScroll({
     if (!dataSource?.length) {
       // TODO:针对无数据的情况下,特别设置tboody
       tableContainerEl!.style.marginBottom = '16px'
-      const tbodyEl: HTMLElement = tableContainerEl?.querySelector('.ant-table-tbody')
+      const tbodyEl: HTMLElement = tableContainerEl?.querySelector('tbody.ant-table-tbody')
       const el = tableContainerEl?.querySelector('table')
       let hasScrollBar = el?.style.width !== '100%'
 
@@ -98,6 +98,7 @@ export function useTableScroll({
       return
     }
     const tbodyEl: HTMLElement = tableContainerEl?.children[1]
+
     tbodyEl && (tbodyEl!.style.height = `${height}px`)
   }