Skip to content
This repository has been archived by the owner on Mar 7, 2024. It is now read-only.

Commit

Permalink
fix: 修正支付宝 events 事件不触发的问题
Browse files Browse the repository at this point in the history
  • Loading branch information
yesmeck committed Aug 28, 2019
1 parent d085862 commit dbf6e09
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 4 deletions.
33 changes: 29 additions & 4 deletions packages/remax/src/createPageConfig.ts
Original file line number Diff line number Diff line change
Expand Up @@ -74,8 +74,8 @@ export default function createPageConfig(Page: React.ComponentType<any>) {
return this.callLifecycle(Lifecycle.hide);
},

onPullDownRefresh() {
return this.callLifecycle(Lifecycle.pullDownRefresh);
onPullDownRefresh(e: any) {
return this.callLifecycle(Lifecycle.pullDownRefresh, e);
},

onReachBottom() {
Expand All @@ -98,14 +98,39 @@ export default function createPageConfig(Page: React.ComponentType<any>) {
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
*/
Expand Down
8 changes: 8 additions & 0 deletions packages/remax/src/lifecycle.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,21 @@ export enum Lifecycle {
optionMenuClick = 'optionMenuClick',
popMenuClick = 'popMenuClick',
pullIntercept = 'pullIntercept',
back = 'back',
keyboardHeight = 'keyboardHeight',
tabItemTap = 'tabItemTap',
beforeTabItemTap = 'beforeTabItemTap',
resize = 'resize',
}

export function hookName(name: string) {
return 'use' + capitalize(name);
}

export function callbackName(name: string) {
if (name.startsWith('before')) {
return capitalize(name);
}
return 'on' + capitalize(name);
}

Expand Down

0 comments on commit dbf6e09

Please sign in to comment.