将内容区域进入全屏和退出
进入全屏
const fullScreen = () => {
var de: any = document.documentElement;
if (de.requestFullscreen) {
// W3C
de.requestFullscreen();
} else if (de.mozRequestFullScreen) {
// FireFox
de.mozRequestFullScreen();
} else if (de.webkitRequestFullScreen) {
// Chrome等
de.webkitRequestFullScreen();
} else if (de.msRequestFullscreen) {
// IE11
de.msRequestFullscreen();
}
document.getElementsByTagName('body')[0].classList.add('full-screen');
// 用于判断页面是否处于全屏状态 -> 进入全屏
state.isFullScreen = true;
};
退出全屏
const exitFullscreen = () => {
var de: any = document;
if (de.exitFullscreen) {
de.exitFullscreen();
} else if (de.mozCancelFullScreen) {
de.mozCancelFullScreen();
} else if (de.webkitExitFullscreen) {
de.webkitExitFullscreen();
} else if (de.msExitFullscreen) {
de.msExitFullscreen();
}
document.getElementsByTagName('body')[0].classList.remove('full-screen');
// 用于判断页面是否处于全屏状态 -> 退出全屏
state.isFullScreen = false;
};