HomeDocs
Skip to main content

Page Navigation

In a Mini Program, all page navigation is managed by the framework.

Page Stack

The framework maintains all current pages in a stack. When a route switch occurs, the page stack behaves as follows:

Routing MethodPage Stack Behavior
InitializationNew page is pushed onto the stack.
Open New PageNew page is pushed onto the stack.
Page RedirectCurrent page is popped from the stack, and the new page is pushed onto the stack.
Page BackPages are popped from the stack until the target return page is reached.
Tab SwitchAll pages are popped from the stack, leaving only the new Tab page.
Page ReloadAll pages are popped from the stack, leaving only the new page.

Developers can use the getCurrentPages() function to get the current page stack.

Routing Methods

For routing trigger methods and page lifecycle functions, refer to the following:

Routing MethodTriggering OccasionPrevious PageDestination Page
InitializationWhen the Mini Program is first opened.onLoad, onShow
Open New PageUsing the dlt.navigateTo API.onHideonLoad, onShow
Page RedirectUsing the dlt.redirectTo API.onUnloadonLoad, onShow
Page BackUsing the dlt.navigateBack API.
User presses the upper-left back button.
onUnloadonShow
Tab SwitchUsing the dlt.switchTab API.
User switches tabs.
Refer to the table below for various cases.
RelaunchUsing the dlt.reLaunch API.onUnloadonLoad, onShow

Tab Switch Corresponding Lifecycles (using A and B pages as Tabbar pages, C is opened from A, and D is opened from C):

Current PageDestination PageTriggered Lifecycles (in order)
AANothing happens
ABA.onHide(), B.onLoad(), B.onShow()
AB (reopen)A.onHide(), B.onShow()
CAC.onUnload(), A.onShow()
CBC.onUnload(), B.onLoad(), B.onShow()
DBD.onUnload(), C.onUnload(), B.onLoad(), B.onShow()
D (from share)AD.onUnload(), A.onLoad(), A.onShow()
D (from share)BD.onUnload(), B.onLoad(), B.onShow()

Important Notes:

  • navigateTo and redirectTo can only open non-tabbar pages.
  • switchTab can only open tabbar pages.
  • reLaunch can open any page.
  • The bottom tabbar on a page is determined by that page, meaning any page defined as a tabbar page will have a bottom tabbar.
  • Parameters passed via page routing can be retrieved in the onLoad of the destination page.
Privacy agreementDeveloper agreementcontact us: developer_service.mi@transsion.com © 2024 MiniApp. All Rights Reserved.