You can define the following application lifecycle methods in the app.js file.
| Attribute | Type | Description | Called When |
|---|---|---|---|
| onCreate | () => void | Listens for application creation. | The application is created. |
| onDestroy | () => void | Listens for application destruction. | The application exits. |
You can define the following page lifecycle functions in the .js file of the page.
To avoid affecting the page switching performance, do not perform complex, time-consuming operations in a lifecycle function.
| Attribute | Type | Description | Called When |
|---|---|---|---|
| onInit | () => void | Listens for page initialization. | Page initialization is complete. This function is called only once in the page lifecycle. |
| onReady | () => void | Listens for page creation. | A page is created. This function is called only once in the page lifecycle. |
| onShow | () => void | Listens for page display. | The page is displayed. |
| onHide | () => void | Listens for page hiding. | The page is hidden. |
| onDestroy | () => void | Listens for page destruction. | The page is destroyed. |
The lifecycle functions of page A are called in the following sequence:
