vue H5頁面在微信瀏覽器打開軟鍵盤關閉導致頁面空缺的問題。


methods:{
    inputBlur () {
      // window.scroll(0, 0);
      setTimeout(() => {
        // alert(1);
        if (document.activeElement.tagName === 'INPUT' || document.activeElement.tagName === 'TEXTAREA') {
          return;
        }
        if (/(iPhone|iPad|iPod|iOS)/i.test(navigator.userAgent)) { // 判斷iPhone|iPad|iPod|iOS
          this.valRes = 'ios';
        } else if (/(Android)/i.test(navigator.userAgent)) { // 判斷Android
          this.valRes = 'android';
        }
        if (this.valRes === 'ios') {
          document.activeElement.scrollIntoViewIfNeeded(true);
        }
      }, 10);
    },

}

input失焦事件:
<input  @blur="inputBlur" />
 
         

 

 
        

 


免責聲明!

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



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