typescript设置全屏

Posted pearlran

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了typescript设置全屏相关的知识,希望对你有一定的参考价值。

fullScreen() {
    document.getElementById("fullScreen").style.display = "none";
    document.getElementById("exitScreen").style.display = "block";
    let el = document.documentElement as any;
    let rfs = el.requestFullScreen || el.webkitRequestFullScreen || el.mozRequestFullScreen || el.msRequestFullscreen;
    if (typeof rfs != "undefined" && rfs) {
      rfs.call(el);
    };
    return;
  }

  //退出全屏
  exitScreen() {
    document.getElementById("fullScreen").style.display = "block";
    document.getElementById("exitScreen").style.display = "none";
    let cfs = document as any;
    if (cfs.exitFullscreen) {
      cfs.exitFullscreen();
    }
    else if (cfs.webkitCancelFullScreen) {
      cfs.webkitCancelFullScreen();
    }
    else {
      cfs.msExitFullscreen();
    }
  }

  特别注意:typescript的类型检查时,document内会报msRequestFullscreen不是documentElement的属性。解决方法:重新赋值document as any即可

以上是关于typescript设置全屏的主要内容,如果未能解决你的问题,请参考以下文章

使用viewpager时,片段不会全屏显示

提交带有全屏片段的片段事务

带有透明状态栏的全屏片段(以编程方式)

typescript Angular 2测试片段。代码库https://developers.livechatinc.com/blog/category/programming/angular-2/

typescript Angular最终版本的Angular 2测试片段。代码库https://developers.livechatinc.com/blog/category/programming

typescript Angular最终版本的Angular 2测试片段。代码库https://developers.livechatinc.com/blog/category/programming