1、使用Vue框架在移动端,调起软键盘的时候,有的安卓机输入框会被盖住,直接上代码:
<script>
export default ({
data () {
return {
}
},
created () {
var u = navigator.userAgent
if (u.indexOf('Android') > -1 || u.indexOf('Adr') > -1) {
this.onFoucs()
}
},
methods: {
onFoucs () {
window.addEventListener('resize', function () {
if (document.activeElement.tagName === 'INPUT' || document.activeElement.tagName === 'TEXTAREA') {
window.setTimeout(function () {
document.activeElement.scrollIntoView()
}, 1)
}
})
},
}
})
</script>