File size: 460 Bytes
81d8726
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
import { ref, onMounted, onUnmounted } from 'vue'

export default function useMobileWidth(maxWidth = 968) {
  const isMobileScreen = ref(window.innerWidth < maxWidth)
  function updateScreenWidth() {
    isMobileScreen.value = window.innerWidth < maxWidth
  }
  onMounted(() => {
    window.addEventListener('resize', updateScreenWidth)
  })

  onUnmounted(() => {
    window.removeEventListener('resize', updateScreenWidth)
  })
  return { isMobileScreen }
}