The life cycle of the uni-app framework

The life cycle of the uni-app framework is similar to that of the Vue framework, which mainly includes the following events:

  1. onLaunch: The applet initialization event, which is only triggered once when the applet is initialized.

  2. onShow: Triggered when the applet starts or enters the foreground from the background. It is often used for page opening statistics and data preloading.

  3. onHide: Triggered when the applet enters the background from the foreground, often used for page closing statistics and data saving.

  4. onError: Triggered when an error occurs in the applet, often used for error capture and reporting.

  5. onPageNotFound: Triggered when the applet page does not exist, often used for page redirection and error handling.

  6. onLoad: Fired when the page loads, only fires once when the page loads for the first time.

  7. onReady: The initial page rendering completion event, indicating that the page has been rendered and can be operated.

  8. onUnload: Triggered when the page is unloaded, when the page is destroyed or when the page is closed.

  9. onPullDownRefresh: A pull-down refresh event, triggered when the user pulls down to refresh.

  10. onReachBottom: Pull up bottom event, triggered when the page scrolls to the bottom.

  11. onShareAppMessage: Triggered when the user clicks the share button or "forward" in the upper right menu. It is often used to share pages and share statistics.

  12. onResize: The global window size change event of the applet, which is often used to obtain the screen size and respond to screen rotation.

Generally speaking, the life cycle of the uni-app framework is similar to that of the Vue framework, but there are some differences, which need to be selected and used according to the actual situation.

Guess you like

Origin blog.csdn.net/m0_72446057/article/details/129686282