提交 297c5f04 编写于 作者: 陈晨

fix:修复安卓手机focus软键盘不会自动弹出的bug,软键盘弹出位置修正

上级 d9c3f76b
<template>
<uni-input
@change.stop
<uni-input
@change.stop
v-on="$listeners">
<div
ref="wrapper"
......@@ -33,13 +33,13 @@
</template>
<script>
import {
emitter
emitter, keyboard
} from 'uni-mixins'
const INPUT_TYPES = ['text', 'number', 'idcard', 'digit', 'password']
const NUMBER_TYPES = ['number', 'digit']
export default {
name: 'Input',
mixins: [emitter],
mixins: [emitter, keyboard],
model: {
prop: 'value',
event: 'update:value'
......@@ -166,6 +166,8 @@ export default {
}
this.focus && this._focusInput()
this.initKeyboard(this.$refs.input)
},
beforeDestroy () {
this.$dispatch('Form', 'uni-form-group-update', {
......@@ -225,6 +227,10 @@ export default {
},
_focusInput () {
setTimeout(() => {
this.plusReady(() => {
plus.key.showSoftKeybord()
})
this.$refs.input.focus()
}, 350)
},
......@@ -308,7 +314,7 @@ uni-input[hidden] {
height: 100%;
background: none;
color: inherit;
opacity: 1;
opacity: 1;
-webkit-text-fill-color: currentcolor;
font: inherit;
line-height: inherit;
......
......@@ -16,4 +16,9 @@ export {
export {
default as subscriber
}
from './subscriber'
from './subscriber'
export {
default as keyboard
}
from './keyboard'
export default {
name: 'Keyboard',
props: {
cursorSpacing: {
type: Number,
default: 0
},
adjustPosition: {
type: Boolean,
default: true
}
},
methods: {
plusReady (callback) {
if (!callback) {
return
}
if (window.plus) {
return callback()
}
document.addEventListener('plusready', callback)
},
initKeyboard (el) {
el.addEventListener('focus', () => {
this.plusReady(() => {
var currentWebview = plus.webview.currentWebview()
var style = currentWebview.getStyle() || {}
if (style.softinputMode === 'adjustResize') {
return
}
var rect = this.$el.getBoundingClientRect()
currentWebview.setSoftinputTemporary && currentWebview.setSoftinputTemporary({
mode: this.adjustPosition ? 'adjustPan' : 'nothing',
position: {
top: rect.top,
height: rect.height + this.cursorSpacing
}
})
})
})
}
}
}
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册