解決方案
大概思路就是安卓手機(jī)調(diào)用鍵盤時 會往上擠 導(dǎo)致clientHeight變化薪铜,定位會針對當(dāng)前區(qū)域變化 導(dǎo)致fixed往上偏移
解決: 檢測屏幕變化 將此fixed隱藏 當(dāng)回歸原來高的大小的時候 在顯示
<!-- 此為fixed定位 -->
<div v-if="hidshow" class="fixed">這是fixed定位</div>
data() {
return {
hidshow: true
}
}
mounted() {
// 獲取瀏覽器可視區(qū)域高度
var u = navigator.userAgent;
var isIos = !!u.match(/\(i[^;]+;(U;)?CPU.+Mac OS X/);
if (!isIos) {
// 鍵盤彈起事件
var _this = this;
var docmHeight = document.documentElement.clientHeight || document.body.clientHeight;
window.onresize = function () {
var resizeHeight = document.documentElement.clientHeight || document.body.clientHeight;
if (resizeHeight < docmHeight) {
_this.hidshow = false;
} else {
_this.hidshow = true;
}
};
}
}