解决vue中绝对定位或固定定位在底部的按钮被键盘顶起的问题

解决方式:

export default {

    data() {

        return {

originalHeight: 0, //原始高度
screenHeight: 0, //实时高度
               }

    },

methods:{

watchResize() {
  //实时变化的窗口高度
  this.screenHeight = document.documentElement.clientHeight;
}
},

watch:{
  screenHeight(newHeight) { //监听屏幕高度变化
    this.showBtn = this.originalHeight <= newHeight;
  }
},
    mounted() {

//首次进入的原始高度
this.originalHeight = document.documentElement.clientHeight || document.body.clientHeight;;
  window.addEventListener('resize', this.watchResize);
       },
beforeDestroy() {
  window.removeEventListener("resize", this.watchResize);

}
 }

 

你可能感兴趣的:(vue,js,js,vue)