VUE再有底部导航栏fixed定位时点击输入框底部的导航栏随着键盘上升的问题

在安卓系统下点击输入框会改变了窗口的高度使底部导航栏上升。
解决办法:

data() {
    return {
      userInfo: {},
      docmentHeight: "0", //默认屏幕高度
      showHeight: "0", //实时屏幕高度
      hidshow: true, //显示或者隐藏footer
      isResize: false //默认屏幕高度是否已获取
    };
  },
  mounted() {
    //在mounted中首先获取正常情况下的屏幕高度
    if (!this.isResize) {
      // 默认屏幕高度
      this.docmentHeight = document.documentElement.clientHeight;
      this.isResize = true;
      console.log("docmentHeight=" + this.docmentHeight);
    }
    //在屏幕高度发生变化的时候获取屏幕高度
    window.onresize = () => {
      return (() => {
        // 实时屏幕高度
        this.showHeight = document.body.clientHeight;
        console.log("showHeight=" + this.showHeight);
      })();
    };
  },
  //watch来监听屏幕变化
  watch: {
    showHeight: function() {
      console.log("Function:showHeight");
      //如果正常的高度大于变化后的高度,那么我们就隐藏下面的导航栏
      if (this.docmentHeight > this.showHeight) {
        this.hidshow = false;
      } else {
        this.hidshow = true;
      }
    }
  },
//这边是我封装的一个底部导航栏组件,当v-show为false时隐藏,true时显示
<c-tabbar v-show="hidshow"></c-tabbar>
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值