前提:使用ionic
1.html模板中设置属性:data-prevent-inoic1-focus为true,data-tap-disabled为true
2.绑定focus事件,事件中处理将当前操作元素滚动到视图内
3.定时间隔视情况而定,目前200ms即可
4.ios可能会出现焦点乱跑的情况,可以尝试以下兼容的方式
// 将元素滚动到视图中,解决键盘遮挡
scrollToView(child) {
if (this.commonData.platform.toLowerCase() === 'ios') {
child.scrollIntoView();
} else {
setTimeout(() => {
child.scrollIntoView(true);
}, 200);
}
}