1.在data里面定义:
data(){
return{
isScreen:false,
}
}
//是否显示全屏
fullScreen(event){
this.isScreen = !this.isScreen;
var elem=document.body;
if(this.isScreen == true){
if(elem.webkitRequestFullScreen){
elem.webkitRequestFullScreen();
}else if(elem.mozRequestFullScreen){
elem.mozRequestFullScreen();
}else if(elem.requestFullScreen){
elem.requestFullscreen();
}else{
console.log("浏览器不支持全屏API或已被禁用 ");
}
}else{
document.exitFullscreen?document.exitFullscreen():
document.mozCancelFullScreen?document.mozCancelFullScreen():
document.webkitExitFullscreen?document.webkitExitFullscreen():'';
}
},