Skip to content
On this page

useFullscreen

管理 DOM 全屏的 Hook。

代码演示

图片全屏

API

const [
  isFullscreen,
  {
    enterFullscreen,
    exitFullscreen,
    toggleFullscreen,
    isEnabled,
  }] = useFullScreen(
    target,
    options?: Options
  );
const [
  isFullscreen,
  {
    enterFullscreen,
    exitFullscreen,
    toggleFullscreen,
    isEnabled,
  }] = useFullScreen(
    target,
    options?: Options
  );

Params

参数说明类型
targetDOM 节点或者 refElement
option设置Options

Options

参数说明类型默认值
onExit退出全屏触发() => void-
onEnter全屏触发() => void-
defaultElement默认全屏元素Element | HTMLElementhtml

Result

参数说明类型
isFullscren是否全屏Readonly<Ref<boolean>>
enterFullscreen设置全屏() => void
exitFullscreen退出全屏() => void
toggleFullscreen切换全屏() => void
isEnabled是否支持全屏boolean

Source

源码文档示例