Skip to content

useDocumentVisibility

Category
Export Size
542 B
Last Changed
15 minutes ago

响应式跟踪 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

SourceDemoDocs

贡献者

Anthony Fu
丶远方
Antério Vieira
Anthony Fu
vaakian X
Jelf
Shinigami
wheat
Alex Kozack
Scott Bedard

变更日志

v9.11.0 on 1/17/2023
d5321 - fix(components): mark defineComponent as pure (#2623)

Released under the MIT License.