小程序路由及路由传参

小程序大部分都是封装好的API,虽然形式类似vue,但是还是有很多新的API要学习。首先就是解决页面跳转的问题。小程序有三种形式的跳转:

1. wx.navigateTo (非 tabBar 的页面的路径,能返回来,只能有五层)

wx.navigateTo({
url: '../placeIntroduce/placeIntroduce?placeId=2',
})
另外一个页面通过onload(options) 获取到placeId

2. wx.redirectTo (非 tabBar 的页面的路径,不能返回来,不限层)

wx.redirectTo ({
url: '../placeIntroduce/placeIntroduce?placeId=2',
})

3. wx.switchTab (关闭其他所有非 tabBar 页面)

原文地址:https://www.cnblogs.com/panax/p/9661450.html