解決vueIOS調起鍵盤後頁面底部留白的問題

<input ref="input" v-reset-page v-focus type="tel"placeholder="請輸入手機號碼">
複製代碼
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)
          }
        });
      }
    }
複製代碼
相關文章
相關標籤/搜索