安卓手機點擊input 自帶鍵盤會擋住輸入框的問題

1.寫個js即可(對於vue項目,將js寫在mounted即可)

 // 處理安卓手機輸入法遮擋輸入框問題
    if ((/Android/gi).test(navigator.userAgent)) {
        window.addEventListener('resize', function () {
            if (document.activeElement.tagName == 'INPUT' || 
                document.activeElement.tagName == 'TEXTAREA') {
                window.setTimeout(function () {
                    document.activeElement.scrollIntoViewIfNeeded();
                }, 0);
            }
        });
    }

寫上這段js 點擊input 會自動將input顯示在可視區域

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章