ios键盘遮挡输入框问题
Posted codecz6
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了ios键盘遮挡输入框问题相关的知识,希望对你有一定的参考价值。
/**
* @description: 输入框焦点
* @param *
* @return *
*/
focusField()
const activeElement = document.activeElement;
let offsetTop = activeElement.offsetTop;
let offsetParent = activeElement.offsetParent;
if (activeElement === document.body)
return;
while (offsetParent !== document.body)
offsetTop += offsetParent.offsetTop;
offsetParent = offsetParent.offsetParent;
// console.log("clientHeight", document.body.clientHeight);
// console.log(offsetTop); // 距离最外层body的高度
const viewTop = document.querySelector(".content").offsetTop;
// console.log(viewTop);// content距离最外层body的高度
document.querySelector(".container").scrollTop = offsetTop - viewTop - 50;
// console.log(document.querySelector(".container").scrollTop);
,
以上是关于ios键盘遮挡输入框问题的主要内容,如果未能解决你的问题,请参考以下文章