js-解決安卓手機軟鍵盤彈出后,固定定位布局被頂上移問題


分析:軟鍵盤彈出后,導致頁面高度變化

解決方案:軟鍵盤彈出后,修復頁面高度

// 監聽窗口變化
    resizeScreen(){
      if (!this.state.isIOS && this.state.isInApp) {
            var originHeight = document.documentElement.clientHeight || document.body.clientHeight;
            this.$nextTick(()=>{
              let bodyE = document.querySelector('.pop-other');
              window.addEventListener('resize', function() {
                  var resizeHeight = document.documentElement.clientHeight || document.body.clientHeight;
                  if (originHeight < resizeHeight) {
                      console.log('Android 鍵盤收起啦!');
                      // Android 鍵盤收起后操作
                      bodyE.style.height = 100+'%';
                  } else {
                      console.log('Android 鍵盤彈起啦!');
                      // Android 鍵盤彈起后操作
                      bodyE.style.height = originHeight+'px';
                  }
                  originHeight = resizeHeight;
              }, false)
            });
        }
    },

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM