1.data里定义 默认屏幕高度和实时屏幕高度
data(){
return{
defaultHeight: '0', //默认屏幕高度
nowHeight: '0', //实时屏幕高度
}
}
2.获取 默认屏幕高度和实时屏幕高度
mounted: function() {
//获取默认高度
this.defaultHeight = $(window).height();
window.onresize = () => {
return (() => {
//实时屏幕高度
this.nowHeight =$(window).height();
})();
};
},
3.监听 键盘状态
watch: {
nowHeight:function() {
if(this.defaultHeight!= this.nowHeight){
//键盘弹出操作
}else{
//键盘不弹出操作
}
}
}