From 78832907fc9a793008b0198f217478524fb0f711 Mon Sep 17 00:00:00 2001 From: ocean_gao Date: Thu, 8 Aug 2024 19:04:54 +0800 Subject: [PATCH] =?UTF-8?q?fix(Table):=20=E5=85=BC=E5=AE=B9=20windows=20?= =?UTF-8?q?=E6=B5=8F=E8=A7=88=E5=99=A8=E6=BB=9A=E5=8A=A8=E6=9D=A1=E5=AF=BC?= =?UTF-8?q?=E8=87=B4=E9=AB=98=E5=BA=A6=E6=9C=89=E5=B0=8F=E6=95=B0=E7=9A=84?= =?UTF-8?q?=E5=9C=BA=E6=99=AF=20(#872)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- components/table/useTableLayout.ts | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/components/table/useTableLayout.ts b/components/table/useTableLayout.ts index 266f9f18..a70aeff6 100644 --- a/components/table/useTableLayout.ts +++ b/components/table/useTableLayout.ts @@ -1,5 +1,6 @@ import { type Ref, + computed, nextTick, onActivated, onDeactivated, @@ -45,6 +46,9 @@ export default function useTableLayout({ const bodyHeight = ref(0); const initRef = ref(false); + // 兼容 windows 浏览器滚动条导致高度有小数的场景 + const propHeight = computed(() => Math.floor(props.height)); + const min = 80; const computeY = () => { @@ -54,12 +58,12 @@ export default function useTableLayout({ const $wrapper = wrapperRef.value; const $bodyWrapper = bodyWrapperRef.value; if ($wrapper && $bodyWrapper) { - if (props.height) { + if (propHeight.value) { const $headerWrapper = props.showHeader ? headerWrapperRef.value : { offsetHeight: 0 }; const headerWrapperHeight = $headerWrapper.offsetHeight; - let remainBodyHeight = props.height - headerWrapperHeight; + let remainBodyHeight = propHeight.value - headerWrapperHeight; if (props.bordered) { remainBodyHeight -= 2; } @@ -159,7 +163,7 @@ export default function useTableLayout({ watch( [ widthMap, - () => props.height, + propHeight, () => props.showHeader, () => props.bordered, wrapperRef,