移動端鍵盤遮擋

前提:使用ionichtml

1.html模板中設置屬性:data-prevent-inoic1-focus爲true,data-tap-disabled爲trueios

 

2.綁定focus事件,事件中處理將當前操做元素滾動到視圖內ionic

 

3.定時間隔視狀況而定,目前200ms便可this

 

4.ios可能會出現焦點亂跑的狀況,能夠嘗試如下兼容的方式spa

 

 1 // 將元素滾動到視圖中,解決鍵盤遮擋
 2   scrollToView(child) {
 3     if (this.commonData.platform.toLowerCase() === 'ios') {
 4       child.scrollIntoView();
 5     } else {
 6       setTimeout(() => {
 7         child.scrollIntoView(true);
 8       }, 200);
 9     }
10   }
相關文章
相關標籤/搜索