14 lines
366 B
JavaScript
14 lines
366 B
JavaScript
import { reactive } from 'vue';
|
|
|
|
const mobileMediaQuery = 'screen and (max-width: 768px)';
|
|
const matchMedia = window.matchMedia(mobileMediaQuery);
|
|
|
|
const isMobile = reactive(matchMedia.matches);
|
|
|
|
matchMedia.addEventListener('change', (event) => {
|
|
isMobile = event.matches;
|
|
});
|
|
|
|
export const install = (app) => {
|
|
app.config.globalProperties.$isMobile = isMobile;
|
|
} |