共计 500 个字符,预计需要花费 2 分钟才能阅读完成。
const scrollToTop = () => {if (!isAndroidApp) {window.scrollTo(0, 0);
const inp = document.getElementsByTagName("input");
if (!isApp && inp.length > 0) {
let scrollTopCurrent: any = "";
window.addEventListener("scroll", () => {
var scrollTop = window.pageYOffset || document.body.scrollTop;
if (scrollTop > 0) {scrollTopCurrent = scrollTop;}
});
Array.from(inp).map(item => {item.onblur = () => {window.scrollTo(0, 0);
};
item.onfocus = () => {window.scrollTo(0, scrollTopCurrent);
};
});
}
}
}
正文完