Home > WeChat Applet > Mini Program Development > What are the ways to jump to mini program pages?

What are the ways to jump to mini program pages?

王林
Release: 2021-02-01 13:59:33
forward
4575 people have browsed it

What are the ways to jump to mini program pages?

There are several ways to jump to the mini program page:

1. wx.navigateTo(OBJECT)

This is the most A common jumping method, its official explanation is: "Keep the current page and jump to a page in the application"

is similar to window.location.href=" "
in HTML eg:

wx.navigateTo({ url: 'test?id=1'})
The actual effect is as follows:

What are the ways to jump to mini program pages?

The upper left corner of the applet There is a return arrow in the corner, which can return to the previous page

You can also return to the original page through the method wx.navigateBack

2. wx.redirectTo(OBJECT)

Close the current page and jump to a page within the app.
Similar to window.open('the page you want to jump to');
eg:
wx.redirectTo({ url: 'test?id=1'})
Effect As follows:

What are the ways to jump to mini program pages?

There is no return arrow in the upper left corner, and you cannot return to the previous page

3. wx.switchTab(OBJECT)

Jump to the tabBar page and close all other non-tabBar pages
eg:
{ "tabBar": { "list": [{ "pagePath": "index", "text": "Homepage" },{ "pagePath": "other", "text": "other" }] } }
wx.switchTab({ url: '/index'})

What are the ways to jump to mini program pages?

##wx.navigateTo and wx.redirectTo do not allow jumping to the tabbar page. You can only use wx.switchTab to jump to the tabbar page

4. wx.reLaunch(OBJECT)

Close all pages and open a certain page in the application.

Like wx.redirectTo, there will be no return arrow in the upper left corner, but they are not exactly the same.


Here we should mention the getCurrentPages() method in the mini program


In wx.navigateTo, every time a new page is jumped, its original page will be added to the stack. By calling wx.navigateBack(OBJECT), you can return to the previous level or by getting the page saved in the stack. Multi-level pages;

wx.redirectTo method will not be added to the stack, but you can still return to the page in the previous stack through the wx.navigateBack(OBJECT) method

wx.reLaunch method The current stack will be cleared.

eg:

// 此处是A页面wx.navigateTo({  url: 'B?id=1'})// 此处是B页面wx.navigateTo({  url: 'C?id=1'})// 在C页面内 navigateBack,将返回b页面wx.navigateBack({  delta: 1})
// 此处是B页面
wx.redirectTo({
 url: 'C?id=1'
 })
 // 在C页面内 navigateBack,则会返回a页面 
wx.navigateBack({
 delta: 1
 })
// 此处是B页面
wx.reLaunch({
 url: 'C?id=1'
 })
 // 在C页面内 navigateBack,则无效
Copy after login

Related recommendations:

小program development tutorial

The above is the detailed content of What are the ways to jump to mini program pages?. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
source:cnblogs.com
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template