WeChat applet jump analysis

The triggering method of the route and the page life cycle function are as follows:

routing Trigger timing pre-routing page post-routing page
initialization The first page opened by the applet   onLoad, onShow
open new page Call API  wx.navigateTo or use components <navigator open-type="navigateTo"/> onHide onLoad, onShow
page redirection Call API  wx.redirectTo or use components <navigator open-type="redirectTo"/> onUnload onLoad, onShow
page back Call the API  wx.navigateBack or use the component <navigator open-type="navigateBack">or the user presses the top left back button onUnload onShow
Tab switching Call API  wx.switchTab or use component  <navigator open-type="switchTab"/> or user to switch Tab   Please refer to the table below for various situations
reboot Call API  wx.reLaunch or use components <navigator open-type="reLaunch"/> onUnload onLoad, onShow

The life cycle corresponding to Tab switching (take A and B pages as Tabbar pages, C is a page opened from A page, and D page is a page opened from C page as an example):

The current page post-routing page Triggered lifecycles (in order)
A A Nothing happend
A B A.onHide(), B.onLoad(), B.onShow()
A B (open again) A.onHide(), B.onShow()
C A C.onUnload(), A.onShow()
C B C.onUnload(), B.onLoad(), B.onShow()
D B D.onUnload(), C.onUnload(), B.onLoad(), B.onShow()
D (enter from forward) A D.onUnload(), A.onLoad(), A.onShow()
D (enter from forward) B D.onUnload(), B.onLoad(), B.onShow()

Tips:

  • navigateToredirectTo can only open non-tabBar pages.
  • switchTab Only tabBar pages can be opened.
  • reLaunch Any page can be opened.
  • The tabBar at the bottom of the page is determined by the page, that is, as long as it is a page defined as tabBar, there is a tabBar at the bottom.
  • The parameters of the calling page routing can be obtained in the target page onLoad.

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=325171755&siteId=291194637