search
HomeWeChat AppletMini Program DevelopmentHow to jump between mini programs? How to jump between mini programs

The content of this article is about how to jump between small programs? The method of jumping between small programs has certain reference value. Friends in need can refer to it. I hope it will be helpful to you. [Recommended reading: Mini Program Development Tutorial]

Four methods for mini program page jump

1. wx.navigateTo({}), retain the current page, Jump to a page in the application (the following is the code to jump to the test page), and then use wx.navigateBack to return from the test page to the previous page; the parameters passed by

wx.navigateTo({
    //跳转页面的路径,可带参数 ,用?隔开,不同参数用&分隔;
    url:'../test/test?id=1&page=4',  
    success:function(){}        //成功后的回调;
    fail:function(){}          //失败后的回调;
    complete:function(){}      //结束后的回调(成功,失败都执行)
})

are on the receiving page Get the value in the onLoad() function: option.id can be obtained

onLoad: function (option) {
   console.log(option);  //可以打印一下option查看参数
   this.setData({
   id:option.id
    )};
},

Return to the previous page, bind the return function on the test page

<view class="but" bindtap="fanhui">返回</view>

Write wx in the js of the test page. navigateBack returns

fanhui:function(){
    wx.navigateBack({ changed: true });
},

2. wx.redirectTo(), close the current page and jump to a page other than tabBar;

3. Use the page tag navigator, which is similar to the a tag of html Like;

<navigator url=&#39;../test/test?id=1&#39;>点击跳转</navigator>

4, wx.switchTab, jump to a page in the tabBar;

wx.switchTab({
url: &#39;../taste/index?id=1&#39;,  //注意switchTab只能跳转到tab页面,不能跳转到不带tab的页面
})

Use the tab tab provided by the mini program to switch between pages. It should be noted that we do not need to write code to implement tabs ourselves. The mini program provides ready-made tabs. We only need to configure some parameters in app.json to achieve the effect of tabs. The configuration of the tab tab is achieved through the tabBar option in the app.json file.


The above is the detailed content of How to jump between mini programs? How to jump between mini programs. For more information, please follow other related articles on the PHP Chinese website!

Statement
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

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

Video Face Swap

Video Face Swap

Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Tools

mPDF

mPDF

mPDF is a PHP library that can generate PDF files from UTF-8 encoded HTML. The original author, Ian Back, wrote mPDF to output PDF files "on the fly" from his website and handle different languages. It is slower than original scripts like HTML2FPDF and produces larger files when using Unicode fonts, but supports CSS styles etc. and has a lot of enhancements. Supports almost all languages, including RTL (Arabic and Hebrew) and CJK (Chinese, Japanese and Korean). Supports nested block-level elements (such as P, DIV),

SublimeText3 Linux new version

SublimeText3 Linux new version

SublimeText3 Linux latest version

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)

EditPlus Chinese cracked version

EditPlus Chinese cracked version

Small size, syntax highlighting, does not support code prompt function