useDocumentVisibility
响应式跟踪 document.visibilityState
示例
💡 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>
源码
贡献者
Anthony Fu
一纸忘忧
Antério Vieira
Fernando Fernández
Anthony Fu
vaakian X
Jelf
Shinigami
wheat
Alex Kozack
Scott Bedard