vue 实现全屏功能
vue 实现全屏功能
·
vue 实现全屏功能
html:
<el-button type="primary" class="mr-2 btn-fullscreen" @click="handleFullScreen">
全屏
<el-icon><full-screen /></el-icon>
</el-button>
js:
data(){
return{
fullscreen:false
}
},
methods:{
// 全屏方法
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;
}
}
更多推荐
已为社区贡献6条内容
所有评论(0)