useDocumentVisibility
响应式跟踪 document.visibilityState
Demo
💡 Minimize the page or switch tab then return
用法
js
import { useDocumentVisibility } from '@vueuse/core'
const visibility = useDocumentVisibility()
组件用法
vue
<template>
<UseDocumentVisibility v-slot="{ visibility }">
文档可见性:{{ visibility }}
</UseDocumentVisibility>
</template>
类型声明
typescript
/**
* 响应式 `document.visibilityState`.
*
* @see https://vueuse.org/useDocumentVisibility
*/
export declare function useDocumentVisibility(
options?: ConfigurableDocument,
): Ref<DocumentVisibilityState>
Source
贡献者
Anthony Fu
丶远方
Antério Vieira
Anthony Fu
vaakian X
Jelf
Shinigami
wheat
Alex Kozack
Scott Bedard