h5 解决ios和 Android 输入框无法抬起和ios留白处理:
var u = navigator.userAgent; var isAndroid = u.indexOf('Android') > -1 || u.indexOf('Adr') > -1; //android终端 var isiOS = !!u.match(/\(i[^;]+;( U;)? CPU.+Mac OS X/); //ios终端 if (isiOS) { document.body.addEventListener('focusin', () => { setTimeout(()=>{ document.body.scrollTop=document.body.scrollHeight; },100) }) document.body.addEventListener('focusout', () => { window.scrollTo({ top: 0, left: 0, behavior: 'smooth' }) }) } if (/Android/gi.test(navigator.userAgent)) { window.addEventListener('resize', function () { if (document.activeElement.tagName == 'INPUT' || document.activeElement.tagName == 'TEXTAREA') { window.setTimeout(function () { document.activeElement.scrollIntoView(); }, 100); } }.bind(this)) }