UNPKG

vitepress-plugin-tabs

Version:

A plugin that adds syntax for showing content in tabs.

20 lines (16 loc) 479 B
import { onBeforeMount, onUnmounted, ref } from 'vue' export const useIsPrint = () => { const matchMedia = typeof window !== 'undefined' ? window.matchMedia('print') : undefined const value = ref(matchMedia?.matches) const listener = () => { value.value = matchMedia?.matches } onBeforeMount(() => { matchMedia?.addEventListener('change', listener) }) onUnmounted(() => { matchMedia?.removeEventListener('change', listener) }) return value }