Vue 解决IOS手机webapp软键盘弹起, 导致页面底部留白问题
作者:互联网
Vue.directive('resetPage', { inserted: function(el) { document.body.addEventListener('focusout', () => { if (/(iPhone|iPad|iPod|iOS)/i.test(navigator.userAgent)) { // 软键盘收起的事件处理 setTimeout(() => { const scrollHeight = document.documentElement.scrollTop || document.body.scrollTop || 0 window.scrollTo(0, Math.max(scrollHeight - 1, 0)) }, 100) } }) } })
标签:body,Vue,IOS,软键盘,留白,scrollTop,document,scrollHeight 来源: https://www.cnblogs.com/l24118028/p/14987370.html