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文件中添加点击事件即可
网友评论