提交 c6108502 编写于 作者: Q qiang

Merge branch 'v3' of github.com:dcloudio/uni-app into v3

# Conflicts:
#	src/core/view/components/input/index.vue
#	src/core/view/mixins/index.js
#	src/core/view/mixins/keyboard.js
......@@ -21,4 +21,4 @@ export {
export {
default as keyboard
}
from './keyboard'
from './keyboard'
......@@ -4,17 +4,71 @@ function hideKeyboard () {
export default {
name: 'Keyboard',
props: {
cursorSpacing: {
type: Number,
default: 0
},
adjustPosition: {
type: Boolean,
default: true
}
},
watch: {
focus (val) {
if (val) {
this.showSoftKeybord()
}
}
},
mounted () {
if (this.autoFocus || this.focus) {
this.showSoftKeybord()
}
},
beforeDestroy () {
UniViewJSBridge.unsubscribe('hideKeyboard', hideKeyboard)
},
methods: {
plusReady (callback) {
if (!callback) {
return
}
if (window.plus) {
return callback()
}
document.addEventListener('plusready', callback)
},
initKeyboard (el) {
el.addEventListener('focus', () => {
UniViewJSBridge.subscribe('hideKeyboard', hideKeyboard)
this.setSoftinputTemporary()
})
el.addEventListener('blur', () => {
UniViewJSBridge.unsubscribe('hideKeyboard', hideKeyboard)
})
},
showSoftKeybord () {
this.plusReady(() => {
plus.key.showSoftKeybord()
})
},
setSoftinputTemporary () {
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.
先完成此消息的编辑!
想要评论请 注册