Home > WeChat Applet > Mini Program Development > How to jump between mini programs? How to jump between mini programs

How to jump between mini programs? How to jump between mini programs

云罗郡主
Release: 2019-01-21 15:05:24
Original
6223 people have browsed it

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(){}      //结束后的回调(成功,失败都执行)
})
Copy after login

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
    )};
},
Copy after login

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

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

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

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

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>
Copy after login

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

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

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!

Related labels:
source:csdn.net
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