CMVR-IOT-UI/src/hooks/tableHeight.ts

22 lines
626 B
TypeScript
Raw Normal View History

2025-09-11 15:42:24 +08:00
import { useElementSize } from '@vueuse/core'
import { computed } from 'vue'
/**
* hook
* @param {Ref<HTMLElement | null>} containerRef - ref引用
* @param {boolean} [immediate=true] -
* @returns {Ref<number>}
*/
export function useContainerHeight(containerRef, immediate = true) {
// 存储容器高度的响应式变量
const { height } = useElementSize(containerRef)
const containerHeight = computed(() => {
let offset = height.value + 84
return { height: `calc(100% - ${offset}px)` }
})
return containerHeight;
}