Lifecycle
Use lifecycle callbacks to initialize a Page, handle visibility changes, and release resources when it closes. A Page that reaches its first frame calls onLoad → onShow → onReady. Returning to the same Page calls onShow again.
Lifecycle Callback Table
| Callback | Description | Trigger Timing |
|---|---|---|
onLoad | Listens for page load | Triggered when the page loads, once per page instance |
onShow | Listens for page display | Triggered when the page is displayed or brought to the foreground |
onReady | Listens for the first render completion of the page | After the first frame containing the initial view is presented, once per page instance |
onHide | Listens for the page being hidden | Triggered when the page is hidden or moved to the background |
onUnload | Listens for page unload | Triggered when the page is unloaded |
Lifecycle Demo
Sequence: creation onLoad → display onShow → first-frame presentation onReady; later onHide / onShow cycles end with onUnload.
Callback Details
onLoad(Object query)
Runs once per Page instance. Read the parameters supplied when opening the page from query.
onShow()
Triggered when the page is displayed or brought to the foreground.
onReady()
Runs once per instance after the first frame containing the initial view is actually presented. Template parsing or completed layout alone does not trigger onReady. Returning to an existing page and later setData() calls do not repeat it. Instances unloaded before presentation do not receive a late callback.
onHide()
Triggered when the page is hidden or moved to the background.
onUnload()
Runs when the Page instance is destroyed. Clear timers and release resources that belong to the Page in this callback.
Recommended Reading
- Page Overview
- Page Definition
- Events