import { ref, onMounted, onUnmounted, computed, nextTick } from 'vue' const boxRef = ref() const searchBoxRef = ref() const tableBoxHeight = ref(0) const computedTableBoxHeight = () => { const searchBoxHeight = searchBoxRef.value.clientHeight // 获取DIV的高度 const boxHeight = boxRef.value.clientHeight tableBoxHeight.value = boxHeight - searchBoxHeight - 10 } const packUp = async () => { showSearchItem.value = !showSearchItem.value await nextTick() computedTableBoxHeight() } onMounted(() => { computedTableBoxHeight() window.addEventListener('resize', resizeWindow) }) onUnmounted(() => { window.removeEventListener('resize', resizeWindow) }) const resizeWindow = () => { computedTableBoxHeight() }
标签:tableBoxHeight,const,100%,value,resizeWindow,computedTableBoxHeight,div,ref,页面 From: https://www.cnblogs.com/guwufeiyang/p/17921308.html