实现大屏全屏,只需要这几行代码!

const showFullScreen = () => {
  //获取顶级dom
  const element = document.getElementById('ScreenDisplayWrapper') as HTMLElement;
  if (element) {
    element.requestFullscreen();
    // @ts-ignore
    const requestMethod =
      element.requestFullscreen ||
      // @ts-ignore
      element.webkitRequestFullscreen ||
      element.requestFullscreen ||
      element.requestFullscreen;
    if (requestMethod) {
      requestMethod.call(element);
    }
  }
}

你可能感兴趣的:(前端,javascript,开发语言)