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

Commit

Permalink
fix(web): 修复 onLoad 和 onShow 事件不触发的问题
Browse files Browse the repository at this point in the history
  • Loading branch information
yesmeck committed Jul 16, 2020
1 parent 54bd563 commit f871ae1
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 0 deletions.
12 changes: 12 additions & 0 deletions docs/api/remax-one/lifecycle.md
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,18 @@ useAppEvent('onError', () => {});

## Page 生命周期

## onLoad

页面加载时触发

```js
import { usePageEvent } from 'remax/macro';

...

usePageEvent('onLoad', () => {});
```

## onShow

页面可见时触发。
Expand Down
2 changes: 2 additions & 0 deletions packages/remax-runtime/src/createPageConfig.web.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,8 @@ export default function createPageConfig(Page: React.ComponentType<any>) {

componentDidMount() {
this.setTitle();
page.callLifecycle(Lifecycle.load);
page.callLifecycle(Lifecycle.show);
page.callLifecycle(Lifecycle.ready);

this.handlePageScroll();
Expand Down

1 comment on commit f871ae1

@vercel
Copy link

@vercel vercel bot commented on f871ae1 Jul 16, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.