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='../test/test?id=1'>点击跳转</navigator>
4, wx.switchTab, jump to a page in the tabBar;
wx.switchTab({ url: '../taste/index?id=1', //注意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!