Vue 手机端监听屏幕的高度

  mounted() {
    this.judgePhone()
    //监听事件
    window.onresize = () => {
      return (() => {
        this.showHeight = document.documentElement.clientHeight || document.body.clientHeight;
        this.judgePhone()
      })()
    }

  },
 
    judgePhone() {
      let reg = /iphone/gi;
      let ag = navigator.userAgent.toLowerCase()
      let {screen} = window
      if (reg.test(ag) && screen.width === 375 && screen.height === 812) {
       this.$refs.login.style.backgroundPositionY='-20%'
        this.$refs.bottomText.style.bottom="15%";
      }else if(reg.test(ag)){
        this.$refs.login.style.backgroundPositionY='-50%'
        this.$refs.bottomText.style.bottom="5%";
      }
    },
 
 
工作中如果有您解决不了的问题或者您花费2小时还没解决的问题,这里可以有偿帮您高效直接解决bug,wx号:18062748486,备注”bug解决“;

posted on 2022-05-18 12:09  艾小码  阅读(151)  评论(0编辑  收藏  举报

导航