dandanyajin
今天更新博客了吗?
 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   },

 

posted on 2022-07-27 10:52  dandanyajin  阅读(641)  评论(0编辑  收藏  举报