wms-antdvue/.svn/pristine/25/252591971b45fcdb2b3eff6e2494737e927acbdd.svn-base
2024-11-07 16:33:03 +08:00

24 lines
472 B
Plaintext

import { ref, onMounted, onUnmounted } from 'vue';
import { debounce } from 'lodash-es';
/**
* description: 获取页面宽度
*/
export function useDomWidth() {
const domWidth = ref(window.innerWidth);
function resize() {
domWidth.value = document.body.clientWidth;
}
onMounted(() => {
window.addEventListener('resize', debounce(resize, 80));
});
onUnmounted(() => {
window.removeEventListener('resize', resize);
});
return domWidth;
}