The way the page jumps

navigate

Uni. NavigateTo ({url: "the test? Id = 1 & name = uniapp "})Copy the code

Keep the current page and go to a page in the application

redirect

Uni. RedirectTo ({url: "the test? Id = 1 & name = uniapp "})Copy the code

Close the current page and switch to a page in the application

switchTab

Uni. SwitchTab ({url: "the test? Id = 1 & name = uniapp "})Copy the code

Jump to the tabBar page and close all other non-Tabbar pages

reLaunch

Uni. ReLaunch ({url: "the test? Id = 1 & name = uniapp "})Copy the code

Close all pages, open a page in the application bytedance applet is not supported

navigateBack

Uni. NavigateBack ({url: "the test? Id = 1 & name = uniapp "})Copy the code

Close the current page and return to the previous page or multi-level page

The life cycle

OnLoad (){console.log(' page load ')}, onShow() {console.log(' page display ')}, onReady(){console.log(' page display ')}, OnHide (){console.log(' page hide ')}, onUnload() {console.log(' page unload ')}, onBackPress(){console.log(' page return... ')}, onShareAppMessage() {console.log(' share ')}, onReachBottom() {console.log(' drop down load... ')}, onPageScroll(){console.log(' Page scroll... ')}, onPullDownRefresh() {console.log(' pull up refresh... ') uni.stopPullDownRefresh(); },Copy the code

1, the page loading process is: load – display – load completion – page hide – page unloading

2, page life cycle start process: onLoad: listener page load –> onShow: listener page display –> onReady: listener page first render complete –> onHide: listener page hide –> onUnload: listener page unload

3, onLoad and onLoadonShow difference

(1)onShow: monitor page display. Fires every time the page appears on the screen, including returning from sub-page points to reveal the current page

For example, page B: The cache is used to switch to page A

NewMember uni.setStorageSync(‘newMember’, this.newmember)

OnShow () {let STR = uni.getStoragesync (‘newMember’)},

(2) onLoad: load only once, listen to the page load, its parameter is the data passed in the last page, parameter type is Object (used for page parameter transmission)

NavigateBack (uni){uni. NavigateBack ({delta: 1,}) {uni

Summary: After page A jumps to page B, onLoad will not be reloaded when page A is returned from secondary page B, but onshow will be reloaded.

4, If you jump from one page to another page with parameters, get parameters from another page: onLoad(options){console.log(options.xxx)}, these parameters are hanging in options.

5. We use onload when the data changes less

  • OnLoad is executed before onShow
  • The onLoad page is executed only once in its lifetime
  • The onShow page can be executed multiple times over the life of the page, that is, each time it is displayed
  • Events that get parameters and only request once are placed in onLoad.
  • The current page needs to constantly swipe data requests for multiple events placed in onShow.