在安卓系统下点击输入框会改变了窗口的高度使底部导航栏上升。
解决办法:
data() {
return {
userInfo: {},
docmentHeight: "0", //默认屏幕高度
showHeight: "0", //实时屏幕高度
hidshow: true, //显示或者隐藏footer
isResize: false //默认屏幕高度是否已获取
};
},
mounted() {
//在mounted中首先获取正常情况下的屏幕高度
if (!this.isResize) {
// 默认屏幕高度
this.docmentHeight = document.documentElement.clientHeight;
this.isResize = true;
console.log("docmentHeight=" + this.docmentHeight);
}
//在屏幕高度发生变化的时候获取屏幕高度
window.onresize = () => {
return (() => {
// 实时屏幕高度
this.showHeight = document.body.clientHeight;
console.log("showHeight=" + this.showHeight);
})();
};
},
//watch来监听屏幕变化
watch: {
showHeight: function() {
console.log("Function:showHeight");
//如果正常的高度大于变化后的高度,那么我们就隐藏下面的导航栏
if (this.docmentHeight > this.showHeight) {
this.hidshow = false;
} else {
this.hidshow = true;
}
}
},
//这边是我封装的一个底部导航栏组件,当v-show为false时隐藏,true时显示
<c-tabbar v-show="hidshow"></c-tabbar>