diff --git a/src/utils/self-adaption.js b/src/utils/self-adaption.js index 60154ed..22fa70b 100644 --- a/src/utils/self-adaption.js +++ b/src/utils/self-adaption.js @@ -1,5 +1,4 @@ import { ref, onMounted, onBeforeUnmount } from 'vue'; - export function useAdaptation(handleChange) { const mediaQuery = '(max-width: 768px)'; const currentDevice = ref(window.matchMedia(mediaQuery).matches ? 'mobile' : 'pc'); @@ -12,8 +11,8 @@ export function useAdaptation(handleChange) { const mediaQueryChangeHandler = event => { const newDevice = event.matches ? 'mobile' : 'pc'; - changeHandler(newDevice); // 使用钩子函数 - currentDevice.value = newDevice; // 更新currentDevice值 + changeHandler(newDevice); + currentDevice.value = newDevice; }; let mediaQueryList;