JS下兼容性比较好的全屏方法

toggleFullscreen() { const elem = document.querySelector('xxxx'); // 得到你想要全屏的DOM元素 if (document.webkitCurrentFullScreenElement || document.mozFullScreenElement) { document.webkitExitFullscreen ? document.webkitExitFullscreen() : ''; document.mozCancelFullScreen ? document.mozCancelFullScreen() : ''; } else { elem.mozRequestFullScreen ? elem.mozRequestFullScreen() : ''; elem.webkitRequestFullScreen ? elem.webkitRequestFullScreen() : ''; } },

【JS下兼容性比较好的全屏方法】chromefirefox下测试通过. chrome 56下, w3c的api其实还没有正规实现, 得加webkit前缀.

    推荐阅读