提交 e30ae5e9 编写于 作者: Q qiang

feat: 支持 offKeyboardHeightChange 方法

上级 9d217c26
......@@ -131,6 +131,7 @@ const device = [
const keyboard = [
'hideKeyboard',
'onKeyboardHeightChange',
'offKeyboardHeightChange',
'getSelectedTextRange'
]
......
......@@ -162,7 +162,8 @@
"uni.createIntersectionObserver": true,
"uni.createMediaQueryObserver": true,
"uni.hideKeyboard": true,
"uni.onKeyboardHeightChange": true
"uni.onKeyboardHeightChange": true,
"uni.offKeyboardHeightChange": true
}
}, {
"name": "event",
......
......@@ -275,6 +275,10 @@ export function invokeCallbackHandler (invokeCallbackId, res, extras) {
return res
}
export function removeCallbackHandler (invokeCallbackId) {
delete invokeCallbacks[invokeCallbackId]
}
export function wrapperUnimplemented (name) {
return function todo (args) {
console.error('API `' + name + '` is not yet implemented')
......
import {
invoke
invoke,
remove
} from 'uni-core/service/bridge'
import {
......@@ -15,5 +16,12 @@ onMethod('onKeyboardHeightChange', res => {
})
export function onKeyboardHeightChange (callbackId) {
// 与微信小程序一致仅保留最后一次监听
remove(callback)
callback = callbackId
}
export function offKeyboardHeightChange () {
// 与微信小程序一致移除最后一次监听
callback = null
}
export function pack (args) {
return args
}
}
export function unpack (args) {
return args
}
export function invoke (...args) {
return UniServiceJSBridge.invokeCallbackHandler(...args)
}
export function remove (args) {
return UniServiceJSBridge.removeCallbackHandler(args)
}
......@@ -8,7 +8,8 @@ export const once = Emitter.$once.bind(Emitter)
export const emit = Emitter.$emit.bind(Emitter)
export {
invokeCallbackHandler
invokeCallbackHandler,
removeCallbackHandler
}
from 'uni-helpers/api'
......@@ -30,4 +31,4 @@ export function subscribeHandler (event, args, pageId) {
export {
publishHandler
}
from 'uni-platform/service/bridge'
from 'uni-platform/service/bridge'
......@@ -3,7 +3,8 @@ import {
} from 'uni-core/service/uni'
import {
invokeCallbackHandler
invokeCallbackHandler,
removeCallbackHandler
} from 'uni-helpers/api'
import {
......@@ -35,6 +36,7 @@ uni.__$wx__ = wx
UniServiceJSBridge.publishHandler = publishHandler
UniServiceJSBridge.invokeCallbackHandler = invokeCallbackHandler
UniServiceJSBridge.removeCallbackHandler = removeCallbackHandler
export default {
__vuePlugin: vuePlugin,
......@@ -44,4 +46,4 @@ export default {
uni,
getApp,
getCurrentPages
}
}
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册