提交 56769ee9 编写于 作者: DCloud-WZF's avatar DCloud-WZF 💬

feat(my-alipay): uni.onKeyboardHeightChange 支持支付宝小程序

上级 c6cfc7c6
...@@ -4,6 +4,10 @@ import { ...@@ -4,6 +4,10 @@ import {
hasOwn hasOwn
} from 'uni-shared' } from 'uni-shared'
import { $on, $off } from 'uni-core/runtime/event-bus'
let onKeyboardHeightChangeCallback
export { export {
setStorageSync, setStorageSync,
getStorageSync, getStorageSync,
...@@ -104,6 +108,21 @@ export function createIntersectionObserver (component, options) { ...@@ -104,6 +108,21 @@ export function createIntersectionObserver (component, options) {
return my.createIntersectionObserver(options) return my.createIntersectionObserver(options)
} }
export function onKeyboardHeightChange (callback) {
// 与微信小程序一致仅保留最后一次监听
if (onKeyboardHeightChangeCallback) {
$off('uni:keyboardHeightChange', onKeyboardHeightChangeCallback)
}
onKeyboardHeightChangeCallback = callback
$on('uni:keyboardHeightChange', onKeyboardHeightChangeCallback)
}
export function offKeyboardHeightChange () {
// 与微信小程序一致移除最后一次监听
$off('uni:keyboardHeightChange', onKeyboardHeightChangeCallback)
onKeyboardHeightChangeCallback = null
}
export { export {
createMediaQueryObserver createMediaQueryObserver
} }
...@@ -24,6 +24,8 @@ import { ...@@ -24,6 +24,8 @@ import {
initSpecialMethods initSpecialMethods
} from './util' } from './util'
import { $emit } from 'uni-core/runtime/event-bus'
const hooks = [ const hooks = [
'onShow', 'onShow',
'onHide', 'onHide',
...@@ -84,6 +86,9 @@ export default function parsePage (vuePageOptions) { ...@@ -84,6 +86,9 @@ export default function parsePage (vuePageOptions) {
// 支付宝小程序有些页面事件只能放在events下 // 支付宝小程序有些页面事件只能放在events下
onBack () { onBack () {
this.$vm.__call_hook('onBackPress') this.$vm.__call_hook('onBackPress')
},
onKeyboardHeight (res) {
$emit('uni:keyboardHeightChange', res)
} }
}, },
__r: handleRef, __r: handleRef,
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册