前提:使用ionic

1.html模板中设置属性:data-prevent-inoic1-focus为true,data-tap-disabled为true

 

2.绑定focus事件,事件中处理将当前操作元素滚动到视图内

 

3.定时间隔视情况而定,目前200ms即可

 

4.ios可能会出现焦点乱跑的情况,可以尝试以下兼容的方式

 

 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   }

 

posted on 2018-09-14 15:44  晏倾风  阅读(136)  评论(0编辑  收藏  举报