From cacf8a0cd7c27555d69f98fba23d7cb75542efbe Mon Sep 17 00:00:00 2001 From: xpyjs Date: Tue, 11 Jun 2024 11:10:02 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E8=A1=A8=E5=A4=B4=E9=AB=98=E5=BA=A6?= =?UTF-8?q?=E9=87=8D=E6=96=B0=E8=AE=BE=E7=BD=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/composables/useDrag.ts | 4 ++-- src/composables/useElement.ts | 10 ++++++++++ 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/src/composables/useDrag.ts b/src/composables/useDrag.ts index 6d42e8f..97350eb 100644 --- a/src/composables/useDrag.ts +++ b/src/composables/useDrag.ts @@ -78,7 +78,7 @@ export default () => { onMounted(() => { const rootRect = rootRef.value?.getBoundingClientRect(); - const { getMaxHeaderHeight } = useElement(); + const { updateHeaderHeight } = useElement(); (el.value as HTMLElement)?.addEventListener('pointerdown', e => { moveLineLeft.value = e.clientX - (rootRect?.left ?? 0); @@ -101,7 +101,7 @@ export default () => { await nextTick(); - $param.headerHeight = getMaxHeaderHeight(); + updateHeaderHeight(); }, onFinally: () => { diff --git a/src/composables/useElement.ts b/src/composables/useElement.ts index 93e20ea..3c39012 100644 --- a/src/composables/useElement.ts +++ b/src/composables/useElement.ts @@ -17,10 +17,20 @@ export default () => { function updateHeaderHeight() { if (!$param.headerHeight) return; + // 删除 ref 中 style 的 height 属性,以便获取真实高度 + tableHeaderRef.value?.style.removeProperty('height'); + ganttHeaderRef.value?.style.removeProperty('height'); + const maxHeight = getMaxHeaderHeight(); if ($param.headerHeight !== maxHeight) { $param.headerHeight = maxHeight; } + + // 重新设置高度 + tableHeaderRef.value && + (tableHeaderRef.value.style.height = `${maxHeight}px`); + ganttHeaderRef.value && + (ganttHeaderRef.value.style.height = `${maxHeight}px`); } return {