diff --git a/packages/remax/src/createPageConfig.ts b/packages/remax/src/createPageConfig.ts index 78bda21c0..19fef7e65 100644 --- a/packages/remax/src/createPageConfig.ts +++ b/packages/remax/src/createPageConfig.ts @@ -74,8 +74,8 @@ export default function createPageConfig(Page: React.ComponentType) { return this.callLifecycle(Lifecycle.hide); }, - onPullDownRefresh() { - return this.callLifecycle(Lifecycle.pullDownRefresh); + onPullDownRefresh(e: any) { + return this.callLifecycle(Lifecycle.pullDownRefresh, e); }, onReachBottom() { @@ -98,14 +98,39 @@ export default function createPageConfig(Page: React.ComponentType) { return this.callLifecycle(Lifecycle.optionMenuClick); }, - onPopMenuClick() { - return this.callLifecycle(Lifecycle.popMenuClick); + onPopMenuClick(e: any) { + return this.callLifecycle(Lifecycle.popMenuClick, e); }, onPullIntercept() { return this.callLifecycle(Lifecycle.pullIntercept); }, + events: { + // 页面返回时触发 + onBack(this: any) { + return this.callLifecycle(Lifecycle.back); + }, + + // 键盘高度变化时触发 + onKeyboardHeight(this: any, e: any) { + return this.callLifecycle(Lifecycle.keyboardHeight, e); + }, + + onTabItemTap(this: any, e: any) { + return this.callLifecycle(Lifecycle.keyboardHeight, e); + }, + + // 点击但切换tabItem前触发 + beforeTabItemTap(this: any) { + return this.callLifecycle(Lifecycle.beforeTabItemTap); + }, + + onResize(this: any, e: any) { + return this.callLifecycle(Lifecycle.keyboardHeight, e); + }, + }, + /** * lifecycle end */ diff --git a/packages/remax/src/lifecycle.ts b/packages/remax/src/lifecycle.ts index b3da3ec8d..7ad2c6209 100644 --- a/packages/remax/src/lifecycle.ts +++ b/packages/remax/src/lifecycle.ts @@ -15,6 +15,11 @@ export enum Lifecycle { optionMenuClick = 'optionMenuClick', popMenuClick = 'popMenuClick', pullIntercept = 'pullIntercept', + back = 'back', + keyboardHeight = 'keyboardHeight', + tabItemTap = 'tabItemTap', + beforeTabItemTap = 'beforeTabItemTap', + resize = 'resize', } export function hookName(name: string) { @@ -22,6 +27,9 @@ export function hookName(name: string) { } export function callbackName(name: string) { + if (name.startsWith('before')) { + return capitalize(name); + } return 'on' + capitalize(name); }