監(jiān)聽頁面中所有input輸入框箍铭,對焦點和失去焦點時做優(yōu)化判斷處理
let inputs = document.getElementsByTagName('input');
let timer = null;
for (let input of inputs) {
input.addEventListener('blur', function() {
timer = setTimeout(() => {
window.scrollTo(0, 0);
timer = null;
}, 0);
}, false);
input.addEventListener('focus', function() {
timer && clearTimeout(timer);
}, false);
}
安卓手機頁面如果設置全屏粮彤,軟鍵盤彈起收回后,整體頁面會被壓縮柏靶;
全屏設置需要針對不同瀏覽器做判斷,否則ios或者安卓會不兼容溃论;
全屏插件---安卓適用
export default {
install(Vue, options) {
Vue.prototype.$screenFull = function () {
let element = document.documentElement;
console.log('全屏', this.fullscreen)
if (this.fullscreen) {
if (document.exitFullscreen) {
document.exitFullscreen();
} else if (document.webkitCancelFullScreen) {
document.webkitCancelFullScreen();
} else if (document.mozCancelFullScreen) {
document.mozCancelFullScreen();
} else if (document.msExitFullscreen) {
document.msExitFullscreen();
}
} else {
if (element.requestFullscreen) {
element.requestFullscreen();
} else if (element.webkitRequestFullScreen) {
element.webkitRequestFullScreen();
} else if (element.mozRequestFullScreen) {
element.mozRequestFullScreen();
} else if (element.msRequestFullscreen) {
// IE11
element.msRequestFullscreen();
}
}
this.fullscreen = !this.fullscreen;
//this.isFullscreen = true
}
}
}