Angular实现全屏效果(F11)
2020-03-04 本文已影响0人
STUDY_67eb
Anguar想实现F11得全屏效果,可以直接前用前端得$event属性
在ts中使用如下代码
```
fullScreen() {
const el = document.body;
const isFullscreen =document['fullScreen'] ||document['mozFullScreen'] ||document['webkitIsFullScreen'];
if (!isFullscreen) {
if (el['requestFullscreen']) {
el['requestFullscreen']();
}else if (el['mozRequestFullScreen']) {
el['mozRequestFullScreen']();
}else if (el['webkitRequestFullscreen']) {
el['webkitRequestFullscreen']();
}
}else {
if (document['exitFullscreen']) {
document['exitFullscreen']();
}else if (document['mozCancelFullScreen']) {
document['mozCancelFullScreen']();
}else if (document['webkitExitFullscreen']) {
document['webkitExitFullscreen']();
}
}
};
```
html文件中添加点击事件即可