const screenWidth = ref(document.body.clientWidth); window.onresize = () => { //屏幕尺寸变化就重新赋值 return (() => { screenWidth.value = document.body.clientWidth })() }