1. 用ion-input ion-textarea的情况下
<ion-input (ionBlur)="onBlur()"></ion-input>
onBlur() {
if (this.platform.is('ios')) {
// 处理微信浏览器ios输入框关闭时,无法正确缩回 true 顶部对齐 false 底部对齐
document.body.scrollIntoView(true);
}
}
2.alertController有输入的情况下
this.alertController.create({
header: '提示',
inputs: [{name: 'OptionName', type: 'text', placeholder: '其他'}],
buttons: [{text: '取消'}, {
text: '确定', handler: (res) => {
// 处理逻辑
}
}]
}).then(alert => {
alert.present().then(() => {
// 这里用alert-input的class类名做判断 有点危险 可直接用input
const inputs = document.querySelectorAll('input.alert-input');
inputs.forEach(input => {
input.addEventListener('blur', () => {
document.body.scrollIntoView(true);
});
});
});
});
————————————————
版权声明:本文为CSDN博主「llxhzm」的原创文章,遵循CC 4.0 BY-SA版权协议,转载请附上原文出处链接及本声明。
原文链接:https://blog.csdn.net/qq_20059455/article/details/88108660