沒有我的日子里你安然無恙 沒有你的世界里我備受煎熬
作為記錄, 忘了可以找到
<template>
<div class="p20">
<div class="w100 h100" style="background: pink" @click="handleFullScreen"></div>
</div>
</template>
<script>
export default {
name: '', // Pascal命名
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();
}
}
// 因?yàn)辄c(diǎn)擊esc也會(huì)觸發(fā)關(guān)閉全屏, 這里采用取反操作
this.fullscreen = !this.fullscreen;
},
},
};
</script>