(1)我们使用app.json文件来对微信小程序进行全局配置,决定页面文件的路径、窗口表现、设置网络超时时间、设置多 tab 等。
App.json文件
{
"pages": [ //页面路径
"pages/index/index",
"pages/logs/index"
],
"window": {
"navigationBarTitleText": "Demo"
},
"tabBar": {
"list": [{
"pagePath": "pages/index/index",
"text": "首页"
},
{
"pagePath": "pages/logs/logs",
"text": "日志"
}]
},
"networkTimeout": {
"request": 10000,
"downloadFile": 10000
}, "debug": true}
(2)pages每一项代表对应页面的【路径+文件名】信息,数组的第一项代表小程序的初始页面。小程序中新增/减少页面,都需要对 pages 数组进行修改。文件名不需要写文件后缀,因为框架会自动去寻找路径.json,.js,.wxml,.wxss的四个文件进行整合。
(3)窗口表现设置。用于设置小程序的状态栏、导航条、标题、窗口背景色。app.json :
{
"window":{
"navigationBarBackgroundColor": "#ffffff",
//导航栏背景颜色
"navigationBarTextStyle": "black",
//导航栏标题颜色,仅支持 black/white
"navigationBarTitleText": "微信接口功能演示",
//导航栏标题文字内容
"backgroundColor": "#eeeeee",
// 窗口的背景色
"backgroundTextStyle": "light"
//下拉背景字体、loading 图的样式,仅支持 dark/light
}
}
在页面的.json里面编写,注意在根节点写,不要画蛇添足加windows节点!page.json文件
{
"navigationBarBackgroundColor": "#ffffff",
"navigationBarTextStyle": "black",
"navigationBarTitleText": "微信接口功能演示",
"backgroundColor": "#eeeeee",
"backgroundTextStyle": "light"
}