微信小程序页面间操作
1.微信小程序一般下方都有标签页,这种标签页通过app.json可以设置
"tabBar": {
"color": "#797c81",
"selectedColor": "#33a6bc",
"backgroundColor": "#f8f8f8",
"borderStyle": "black",
"list": [
{
"pagePath": "pages/index/index",
"text": "首页",
"iconPath": "resources/icon/home.png",
"selectedIconPath": "resources/icon/home-on.png"
},
{
"pagePath": "pages/class/class",
"text": "分类",
"iconPath": "resources/icon/class.png",
"selectedIconPath": "resources/icon/class-on.png"
}
]
},
2.标签页间跳转(标签页一般为同级关系这种标签页跳转一般没有返回关系)
这种跳转页面没有返回bar
wx.reLaunch({
url: "路径?参数名1=" + 参数值+ "&参数名2=" + 参数值
});
3.一级跳二级(如地址列表页面(一级)与新增地址页面(二级)之间跳转,一般需从二级页面返回一级页面)
wx.navigateTo({
url: '路径',
})
4.跳转到tab页并关闭其他所非TAB页面
wx.switchTab({
url: '/index'
})
5.关闭所有页面并跳转
wx.reLaunch({
url: 'test?id=1'
})
6.返回上级页面
wx.navigateBack({})
注:官方文档:https://developers.weixin.qq.com/miniprogram/dev/api/ui-navigate.html#wxrelaunchobject