当前位置:首页 > 开发教程 > js/jQuery教程 >

vue实现移动端弹出键盘功能(防止页面fixed布局错乱)

时间:2022-04-28 17:32 来源:未知 作者:方得始终 收藏

这篇文章主要介绍了vue?解决移动端弹出键盘导致页面fixed布局错乱的问题,通过实例代码给大家分享解决方案,对vue?移动端弹出键盘相关知识感兴趣的朋友一起看看吧

vue实现移动端弹出键盘功能(防止页面fixed布局错乱)

监听页面高度,当键盘弹出时,将按钮隐藏。

data() {
  return {
    docmHeight: document.documentElement.clientHeight ||document.body.clientHeight,
    showHeight: document.documentElement.clientHeight ||document.body.clientHeight,
    hideshow:true //显示或者隐藏footer
  }
 },
watch: {
    //监听显示高度
   showHeight:function() {
     if(this.docmHeight > this.showHeight){
      //隐藏
       this.hideshow=false
     }else{
      //显示
       this.hideshow=true
     }
   }
 },
mounted() {
   //监听事件
   window.onresize = ()=>{
     return(()=>{
       this.showHeight = document.documentElement.clientHeight || document.body.clientHeight;
   })()
   }
  
 },
<div class="bottom" v-show="hideshow">
  <div class="btn">
   <button>确认</button>
   <button>取消</button>
  </div>
 </div>

到此这篇关于vue解决移动端弹出键盘导致页面fixed布局错乱的问题(推荐)的文章就介绍到这了,更多相关vue移动端弹出键盘内容请搜索源码搜藏网以前的文章或继续浏览下面的相关文章希望大家以后多多支持源码搜藏网!


js/jQuery教程阅读排行

最新文章