一个小程序应用程序会包含两种最基本的配置文件,一是全局的app.json和页面的page.json
配置文件中不能出现注释;
首先看一下一个微信小程序的文件目录:
一、全局的app.json
app.json
是当前小程序的全局配置,包括了小程序的所有页面路径、界面表现、网络超时时间、底部 tab 等
字段的含义:
pages
字段 —— 用于描述当前小程序所有页面路径,这是为了让微信客户端知道当前你的小程序页面定义在哪个目录。window
字段 —— 定义小程序所有页面的顶部背景颜色,文字颜色定义等。- 具体看全局配置,全局配置
"tabBar": {
"color": "black",
"backgroundColor": "#ffffff",
"list": [
{
"pagePath": "pages/index/index",
"text": "首页",
"iconPath": "icons/index.png",
"selectedIconPath": "icons/index_active.png"
},
{
"pagePath": "pages/index2/index2",
"text": "页面2",
"iconPath": "icons/index.png",
"selectedIconPath": "icons/index_active.png"
},
{
"pagePath": "pages/logs/logs",
"text": "日志",
"iconPath": "icons/category.png",
"selectedIconPath": "icons/category_active.png"
}
]
},
效果如图:
二、页面配置 page.json
每一个小程序页面也可以使用 page.json文件来对本页面的窗口表现进行配置。