vue+cordova 软键盘弹出遮住输入框
cordova插件ionic-plugin-keyboard
cordova plugin add ionic-plugin-keyboard
https://www.npmjs.com/package/ionic-plugin-keyboard
测试android用的是三星手机,不管bottom设置的是fixed,还是用scrolliotoview方法,都无法将bottom
放到软键盘上面,弹出和没弹出时window.innerHeight都是一样的
其实一开始是查到ionic-plugin-keyboard,插件,但是想到ionic跟vue毫无关系,也怪自己
浪费了很长时间
document.activeElement 是判断活动的元素是哪一个,判断多个input中某一个onfocus
对于这款插件的方法
cordova.plugins.Keyboard.show(); 打开软键盘 cordova.plugins.Keyboard.close(); 关闭软键盘
在mounted中
软键盘弹出监听
window.addEventListener('native.keyboardshow', keyboardShowHandler);
function keyboardShowHandler(e){
setTimeout(function(){
that.$refs.bottom.style.bottom=e.keyboardHeight+'px'
},300)
}
软键盘隐藏监听
window.addEventListener('native.keyboardhide', keyboardHideHandler);
function keyboardHideHandler(e){
setTimeout(function(){
that.$refs.bottom.style.bottom=0+'px'
},300)
}