vue项目中解决底部键盘遮挡问题,适用于多个input框
mounted(){
var that = this;
var winHeight =document.documentElement.clientHeight;
console.log(that.ScrollClass)
window.onresize =function(){
var thisHeight =document.documentElement.clientHeight;
if(winHeight-thisHeight>50){
var u = navigator.userAgent;
var isAndroid = u.indexOf('Android') > -1 || u.indexOf('Adr') > -1; //android终端
if(isAndroid){
setTimeout(function() {
var scrollObj = that.ScrollClass;
scrollObj.scrollIntoView(true);
}, 100);
}
}else{
var u = navigator.userAgent;
var isAndroid = u.indexOf('Android') > -1 || u.indexOf('Adr') > -1; //android终端
if(isAndroid){
setTimeout(function() {
var scrollObj = that.ScrollClass;
scrollObj.scrollIntoView(false);
}, 100);
}
}
}
},
methods:{
getClass:function(e){
console.log(e.target.parentNode.className)
this.ScrollClass = e.target.parentNode;
// this.ScrollClass = e.target.parentNode.className;
console.log(this.ScrollClass)
}
}
网友评论