主题
useDocumentVisibility
反应式性地跟踪 document.visibilityState
¥Reactively track document.visibilityState
示例
💡 Minimize the page or switch tab then return
用法
¥Usage
js
import { useDocumentVisibility } from '@vueuse/core'
const visibility = useDocumentVisibility()
组件用法
¥Component Usage
vue
<template>
<UseDocumentVisibility v-slot="{ visibility }">
Document Visibility: {{ visibility }}
</UseDocumentVisibility>
</template>
类型声明
typescript
/**
* Reactively track `document.visibilityState`.
*
* @see https://vueuse.org/useDocumentVisibility
*/
export declare function useDocumentVisibility(
options?: ConfigurableDocument,
): Ref<DocumentVisibilityState>