美文网首页
Angular实现全屏效果(F11)

Angular实现全屏效果(F11)

作者: STUDY_67eb | 来源:发表于2020-03-04 13:19 被阅读0次

    Anguar想实现F11得全屏效果,可以直接前用前端得$event属性

    在ts中使用如下代码

    ```

    fullScreen() {

    const el = document.body;

    const isFullscreen =document['fullScreen'] ||document['mozFullScreen'] ||document['webkitIsFullScreen'];

      if (!isFullscreen) {

    if (el['requestFullscreen']) {

    el['requestFullscreen']();

        }else if (el['mozRequestFullScreen']) {

    el['mozRequestFullScreen']();

        }else if (el['webkitRequestFullscreen']) {

    el['webkitRequestFullscreen']();

        }

    }else {

    if (document['exitFullscreen']) {

    document['exitFullscreen']();

        }else if (document['mozCancelFullScreen']) {

    document['mozCancelFullScreen']();

        }else if (document['webkitExitFullscreen']) {

    document['webkitExitFullscreen']();

        }

    }

    };

    ```

    html文件中添加点击事件即可

    相关文章

      网友评论

          本文标题:Angular实现全屏效果(F11)

          本文链接:https://www.haomeiwen.com/subject/thtvlhtx.html