效果图
参考:navigator
实例 app- app.js
App({
onLaunch: function () {
console.log('App Launch')
},
onShow: function () {
console.log('App Show')
},
onHide: function () {
console.log('App Hide')
},
globalData: {
hasLogin: false
}
})
- app.json
{
"pages": [
"pages/pageA/navigator",
"pages/pageB/navigate",
"pages/pageC/redirect",
"pages/pageD/pageD"
],
"tabBar": {
"list": [
{
"pagePath": "pages/pageA/navigator",
"text": "页面A"
},
{
"pagePath": "pages/pageD/pageD",
"text": "页面D"
}
]
},
"window": {
"backgroundTextStyle": "light",
"navigationBarBackgroundColor": "#fff",
"navigationBarTitleText": "WeChat",
"navigationBarTextStyle": "black"
}
}
- app.wxss
{
"description": "项目配置文件",
"packOptions": {
"ignore": []
},
"setting": {
"urlCheck": true,
"es6": true,
"postcss": true,
"minified": true,
"newFeature": true,
"autoAudits": false,
"coverView": true,
"showShadowRootInWxmlPanel": true,
"scopeDataCheck": false
},
"compileType": "miniprogram",
"libVersion": "2.10.2",
"appid": "wx8c507272cc079a6a",
"projectname": "navigator",
"debugOptions": {
"hidedInDevtools": []
},
"isGameTourist": false,
"simulatorType": "wechat",
"simulatorPluginLibVersion": {},
"condition": {
"search": {
"current": -1,
"list": []
},
"conversation": {
"current": -1,
"list": []
},
"game": {
"currentL": -1,
"list": []
},
"miniprogram": {
"current": -1,
"list": []
}
}
}
pageA
- navigator.js
Page({})
- navigator.json
{
"navigationBarTitleText": "navigator"
}
- navigator.wxml
跳转到新页面
在当前页打开
切换tab页面
重加载页面
- navigator.wxss
.navigator-hover button{
background-color: #DEDEDE;
}
.other-navigator-hover button{
background-color: #DEDEDE;
}
pageB
- navigate.js
Page({
onLoad: function (options) {
console.log(options)
}
})
- navigate.json
{
"navigationBarTitleText": "navigate页面"
}
- navigate.wxml
新的navigate页面
返回页面A
pageC
- redirect.js
Page({
onLoad: function (options) {
console.log(options)
}
})
- redirect.json
{
"navigationBarTitleText": "redirect页面"
}
- redirect.wxml
重定向页面
pageD
- navigator.js
Page({})
- navigator.wxml
页面D