移动端键盘弹起引起的fixed定位问题/底部固定定位fixed安卓端输入键盘弹起顶到上面问题

在这里插入代码片
```html![在这里插入图片描述](https://img-blog.csdnimg.cn/20200321174006900.jpg?x-os![在这里插入图片描述](https://img-blog.csdnimg.cn/20200321174045586.jpg?x-oss-process=image/watermark,type_ZmFuZ3poZW5naGVpdGk,shadow_10,text_aHR0cHM6Ly9ibG9nLmNzZG4ubmV0L3FxXzQyODU5NDUw,size_16,color_FFFFFF,t_70)s-process=image/watermark,type_ZmFuZ3poZW5naGVpdGk,shadow_10,text_aHR0cHM6Ly9ibG9nLmNzZG4ubmV0L3FxXzQyODU5NDUw,size_16,color_FFFFFF,t_70#pic_center)
<button type="button" class="btn_submit" v-if="isOriginHei" @click="submit(formData)">提交</button>
js
export default {
  components: {},
  data() {
    return {
      formData: {
        remark: ""
      },
      isOriginHei: true,//在页面上控制元素的显示隐藏
      screenHeight: document.body.clientHeight,
      originHeight: document.body.clientHeight, //默认高度在watch里拿来做比较
    };
  },
  name: "",
  mounted() {
      const that = this;
      window.onresize = () => {
        return (() => {
          window.screenHeight = document.body.clientHeight;
          that.screenHeight = window.screenHeight;
        })();
      };
  },
  watch: {
    screenHeight(val) {
      console.log(val)
      val为获取的新的屏幕高度
      if (this.originHeight != val) {
        this.isOriginHei = false;
      } else {
        this.isOriginHei = true;
      }
    }
  },
};
<style>
.btn_submit {
  width: 1.84rem;
  height: 0.4rem;
  position: fixed;
  bottom: 0;
  left: 50%;
  transform: translateX(-50%);
}
</style>
![在这里插入图片描述](https://img-blog.csdnimg.cn/20200321174107364.jpg?x-oss-process=image/watermark,type_ZmFuZ3poZW5naGVpdGk,shadow_10,text_aHR0cHM6Ly9ibG9nLmNzZG4ubmV0L3FxXzQyODU5NDUw,size_16,color_FFFFFF,t_70)
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值