vue 监听移动端软键盘
data:
defaultPhoneHeight:'',
nowPhoneHeight:''
mounted:
mounted(){
this.defaultPhoneHeight = window.innerHeight
window.onresize = ()=>{
this.nowPhoneHeight = window.innerHeight
}
},
destroyed:
destroyed() {
window.onresize = null
}
watch:
nowPhoneHeight:function(){
if(this.defaultPhoneHeight != this.nowPhoneHeight){
//手机键盘被唤起了
alert('手机键盘被唤起了')
}else{
//手机键盘被关闭了。
// alert('手机键盘被关闭了')
}
}