作品分享
问答交流
发现
任务
客服工单
npm install vue-fullscreen
import fullscreen from 'vue-fullscreen' Vue.use(fullscreen)
data中界说:fullscreenFlag:false fullscreen() { // 必要全屏表现的dom元素 let dom = document.getElementById('指定全屏的dom元素') // 调用全屏方法 this.$fullscreen.enter(dom, { wrap: false, callback: f => { this.fullscreenFlag = f } }) }
fullscreen(){ let element = document.body //全屏的dom元素 如果不设置是body许多元素表现不出来 let titleBar = document.getElementsByClassName('titleBar')[0] //整体头部元素 【刷新、最小化、最大化 关闭】 // 判断是否已经是全屏 // 如果是全屏,退出 if (this.fullscreenFlag) { titleBar.style.display = "block" //控制某些元素,非全屏状态下表现或修改样式 if (document.exitFullscreen) { document.exitFullscreen(); } else if (document.webkitCancelFullScreen) { document.webkitCancelFullScreen(); } else if (document.mozCancelFullScreen) { document.mozCancelFullScreen(); } else if (document.msExitFullscreen) { document.msExitFullscreen(); } console.log('已还原!'); } else { // 否则,进入全屏 titleBar.style.display="none" // 控制某些元素,全屏状态下潜伏或修改样式 if (element.requestFullscreen) { element.requestFullscreen(); } else if (element.webkitRequestFullScreen) { element.webkitRequestFullScreen(); } else if (element.mozRequestFullScreen) { element.mozRequestFullScreen(); } else if (element.msRequestFullscreen) { // IE11 element.msRequestFullscreen(); } console.log('已全屏!'); } // 改变当前全屏状态 this.fullscreenFlag = !this.fullscreenFlag; },
举报
Powered by CangBaoKu v1.0 小黑屋藏宝库It社区( 冀ICP备14008649号 )
GMT+8, 2024-11-21 21:35, Processed in 0.121073 second(s), 32 queries.© 2003-2025 cbk Team.