0
点赞
收藏
分享

微信扫一扫

vue项目浏览器全屏相关

小美人鱼失去的腿 2022-02-28 阅读 71

                                                                                        

 data() {
    return {
      fullHeight: document.documentElement.clientHeight,  //页面高度
}
}


mounted() {
    let _this = this 
    if (window.outerHeight === screen.availHeight){
        if(window.outerWidth === screen.availWidth){
          this.isFullScreen = false
        }
      }else{
        this.isFullScreen = true
      }

      window.onresize = () => {
      return (() => {
        window.fullHeight = document.documentElement.clientHeight
        this.fullHeight = window.fullHeight
      })()
    }
  },
  watch:{
    fullHeight(val){  //监听是否是全屏
      if (window.outerHeight === screen.availHeight){
        if(window.outerWidth === screen.availWidth){
          this.isFullScreen = false
        }
      }else{
        this.isFullScreen = true
      }
    }
  },
举报

相关推荐

0 条评论