Skip to content

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>

源代码

源代码示例文档

变更日志

No recent changes

VueUse 中文网 - 粤ICP备13048890号