iframe + exitFullscreen = 报错?Failed to execute 'exitFullscreen' on 'Document'

752 阅读1分钟

当在页面中使用iframe内嵌页面时,当内嵌页面输入无效的地址时会不会报错,只有内嵌页面有页面可以正常展示时,为iframe增添全屏和退出全屏的按钮,退出全屏时会报错:``` Failed to execute 'exitFullscreen' on 'Document': Document not active

    exitFullScreen() {
      let exitFull = null;
      if (document.fullscreenElement) {
        if (document.exitFullscreen) {
          exitFull = document.exitFullscreen();
        } else if (document.mozCancelFullScreen) {
          exitFull = document.mozCancelFullScreen();
        } else if (document.webkitCancelFullScreen) {
          exitFull = document.webkitCancelFullScreen();
        }
        exitFull && exitFull.then(() => {
        console.log('退出全屏')

          this.$emit('input', false);
        });
      }
    },
   特咨询各位大佬,这啥问题呀