安卓手机点击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显示在可视区域

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