Commonly used page monitoring and jumping methods for WeChat applets

WeChat applet commonly used page jump monitoring method

  1. Use the wx.navigateTo(Object object) method to jump, this jump method will keep the current page, and will jump to a certain page in the application, pay special attention, this method cannot jump to the tabbar page, which is our commonly used bottom menu The tabbar page corresponding to the column. Specific sample code:
wx.navigateTo({
    
    
   url: 'url?id=0&name=参数信息',
})

This is just a common usage. If you need data callback, you can refer to WeChat official documentation.
2. Use the wx.navigateBack(Object object) method, this method will close the current page and return to the previous page or multi-level pages. The current page stack can be obtained through getCurrentPages to determine how many layers need to be returned. Specific code example:

wx.navigateBack({
    
    
  delta: 2
})

Among them, delta is the number of returned pages. If delta is greater than the number of existing pages, return to the home page. This is just a common usage. If you need data callback, you can refer to WeChat official documentation.
3. Use the wx.redirectTo(Object object) method to close the current page and jump to a certain page in the application. Same as the wx.navigateTo(Object object) method, jumping to the tabbar page is not allowed. Specific code example:

wx.redirectTo({
    
    
  url: 'test?id=0&name=参数信息'
})

This is just a common usage. If you need data callback, you can refer to WeChat official documentation.
4. Use the wx.reLaunch(Object object) method to close all pages and open a certain page in the application. Specific code examples:

wx.reLaunch({
    
    
  url: 'test?id=0&name=参数信息'
})

This is just a common usage. If you need data callback, you can refer to WeChat official documentation.
5. Use the wx.switchTab(Object object) method to jump to the tabBar page and close all other non-tabBar pages. Specific code examples:

wx.switchTab({
    
    
  url: '需要跳转的页面路径'
})

For more detailed instructions, you can go to the official WeChat documentation for learning and reference:
Official WeChat documentation

Guess you like

Origin blog.csdn.net/weixin_45465881/article/details/130867090