import { ref, onMounted, onUnmounted, nextTick } from 'vue' import { debounce } from '@/utils' export default function useAdaption(proxy, dom, ispagination = true) { const offset = ispagination ? 30 : 0 const maxHeight = ref(0) const onResize = debounce(function() { maxHeight.value = 0 nextTick(() => { maxHeight.value = proxy.$refs[dom].offsetHeight - offset }) }, 500) onMounted(() => { onResize() }) window.addEventListener('resize', onResize) onUnmounted(() => { window.removeEventListener('resize', onResize) }) return { maxHeight, onResize } }