vue 监听虚拟键盘的隐藏和弹出

    this.$nextTick(() => {
       if(isMobile.iOS() || navigator.userAgent?.startsWith('GLPAPP/FIMS/IOS')) {
          document.body.addEventListener('focusin', () => {  //软键盘弹起事件
              this.isZViewAction = false;
          })
          document.body.addEventListener('focusout', () => { //软键盘关闭事件
            this.isZViewAction = true;
          })
          window.addEventListener('focusin', () => {  //软键盘弹起事件
             this.isZViewAction = false;
          })
          window.addEventListener('focusout', () => { //软键盘关闭事件
           this.isZViewAction = true;
          })
       }else{
          const _screenHeight = window.document.documentElement.clientHeight || window.innerHeight;
          window.addEventListener('resize', () => {
              let _body_h = window.document.documentElement.clientHeight || window.innerHeight;
              console.log("isZViewAction==isZViewAction===isZViewAction")
              console.log(_screenHeight);
              console.log(_body_h);  
              if(_screenHeight - _body_h > 50) {
                 this.isZViewAction = false;
              } else {
            }
    });

你可能感兴趣的:(vue 监听虚拟键盘的隐藏和弹出)