const screen = () => {
// 判断屏幕状态
let fullScreen = document.fullscreenElement;
if (!fullScreen) {
// 开启全屏
document.documentElement.requestFullscreen();
} else {
// 关闭全屏
document.exitFullscreen();
}
}
兼容IE浏览器的
const screen = () => {
// 判断屏幕状态
let element=document.documentElement;
if(element.requestFullscreen){
// 标准浏览区
if(!document.fullscreenElement){
element.requestFullscreen();
}else{
document.exitFullscreen();
}
}else if(element.msRequestFullscreen){
// IE浏览器
if(!document.msFullscreenElement){
element.msRequestFullscreen();
}else{
document.msExitFullscreen();
}
}
}