vue开发之全屏事件

在项目中有需求相应浏览器全屏,写了个案例代码

先看看效果吧

vue开发之全屏事件_第1张图片

全屏显示:

vue开发之全屏事件_第2张图片

 

 

html代码:

 
      

js代码

data(){
return {
fullscreen: false
}
}  



// 全屏事件
            handleFullScreen(){
                let element = document.documentElement;
                if (this.fullscreen) {
                    if (document.exitFullscreen) {
                        document.exitFullscreen();
                    } else if (document.webkitCancelFullScreen) {
                        document.webkitCancelFullScreen();
                    } else if (document.mozCancelFullScreen) {
                        document.mozCancelFullScreen();
                    } else if (document.msExitFullscreen) {
                        document.msExitFullscreen();
                    }
                } else {
                    if (element.requestFullscreen) {
                        element.requestFullscreen();
                    } else if (element.webkitRequestFullScreen) {
                        element.webkitRequestFullScreen();
                    } else if (element.mozRequestFullScreen) {
                        element.mozRequestFullScreen();
                    } else if (element.msRequestFullscreen) {
                        // IE11
                        element.msRequestFullscreen();
                    }
                }
                this.fullscreen = !this.fullscreen;
            },

通过fullscreen判断的true和false确定是否相应全屏

 

你可能感兴趣的:(vue,工作知识总结,vue.js,全屏响应)