Skip to content

Commit

Permalink
fix(Table): 兼容 windows 浏览器滚动条导致高度有小数的场景 (#872)
Browse files Browse the repository at this point in the history
  • Loading branch information
ocean-gao committed Aug 8, 2024
1 parent 702a22e commit 7883290
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions components/table/useTableLayout.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import {
type Ref,
computed,
nextTick,
onActivated,
onDeactivated,
Expand Down Expand Up @@ -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 = () => {
Expand All @@ -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;
}
Expand Down Expand Up @@ -159,7 +163,7 @@ export default function useTableLayout({
watch(
[
widthMap,
() => props.height,
propHeight,
() => props.showHeader,
() => props.bordered,
wrapperRef,
Expand Down

0 comments on commit 7883290

Please sign in to comment.