其他分享
首页 > 其他分享> > vue 实现点击全屏和退出全屏

vue 实现点击全屏和退出全屏

作者:互联网

 1 mounted() {
 2     // 监听窗口大小改变,this.isScreenFull的值为是否全屏,若是则true,反之false
 3       window.onresize = () => {
 4         this.isScreenFull = document.fullscreenElement || document.msFullscreenElement || document.webkitFullscreenElement || document.mozFullscreenElement
 5       }
 6   },
 7 methods: {
 8   // 进入全屏
 9     fullScreenHandle(){
10       var element = document.documentElement
11       if(element.webkitRequestFullscreen){
12         element.webkitRequestFullscreen()
13       }else if(element.msRequestFullscreen){
14         element.msRequestFullscreen()
15       }else if(element.mozRequestFullscreen){
16         element.mozRequestFullscreen()
17       }else if(element.requestFullscreen){
18         element.requestFullscreen()
19       }
20     },
21 // 退出全屏
22     exitFullscreenHandle(){
23       if (document.exitFullscreen) {
24         document.exitFullscreen();
25       } else if (document.msExitFullscreen) {
26         document.msExitFullscreen();
27       } else if (document.mozCancelFullScreen) {
28         document.mozCancelFullScreen();
29       } else if (document.webkitCancelFullScreen) {
30         document.webkitCancelFullScreen();
31       }
32     }
33   },

 

标签:vue,webkitCancelFullScreen,msRequestFullscreen,else,点击,全屏,element,document
来源: https://www.cnblogs.com/dandanyajin/p/16524003.html