信息发布→ 登录 注册 退出

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

发布时间:2026-01-11

点击量:

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

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>
在线客服
服务热线

服务热线

4008888355

微信咨询
二维码
返回顶部
×二维码

截屏,微信识别二维码

打开微信

微信号已复制,请打开微信添加咨询详情!