小程序根目录下的 app.json
文件用来对微信小程序进行全局配置,决定页面文件的路径、窗口表现、设置网络超时时间、设置多 tab 等。html
示例json
{ "pages": [ "pages/index/index", "pages/logs/logs", "pages/klass/klass", ], "window": { "backgroundTextStyle": "light", "navigationBarBackgroundColor": "#1aad16", "navigationBarTextStyle": "black" }, "tabBar": { "color": "black", "selectedColor": "#129763", "list": [ { "text": "首页", "pagePath": "pages/index/index" }, { "text": "修改班级", "pagePath": "pages/klass/klass" } ] } "debug": true }
pages
页面路径window
页面的窗口表现tabBar
底部菜单栏debug
是否开启debug
模式,debug
模式下控制台会打印出详细调试信息小程序
更多关于app.json,详细见 官方文档
1. navigator微信小程序
open-type
的属性值微信
navigate 跳转到 (默认属性) switchTab 以tab(菜单栏)方式切换页面 reLaunch 从新加载url页面,顶部不会出现回退按钮
示例网络
<!-- open-type的默认值为navigate --> <navigator url='/pages/personal/personal'>跳转到修改我的信息界面</navigator> <!-- open-type设置属性值为reLaunch --> <navigator url='/pages/password/password' open-type='reLaunch' >跳转到修改密码界面</navigator> <!-- open-type的默认值为switchTab --> <navigator url='/pages/klass/klass' open-type='switchTab'>跳转到修改班级界面</navigator>
open-type
默认属性,顶部会出现回退样式: app
open-type
设置属性值为reLaunch,顶部不会出现回退样式:框架
open-type
设置属性值为switchTab(*要实现以tab方式切换页面,在app.json中要配合写上tab的配置项
):xss
2.使用API进行导航跳转(实现按钮点击跳转)url
navigate
对应wx.navigateTo(OBJECT)
跳转到switchTab
对应 wx.switchTab(OBJECT)
跳转到某个tabreLaunch
对应 wx.reLaunch(OBJECT)
从新加载
index.js
index.wxml
关于
navigator
的更多属性值可在
官方文档查阅