小程序的配置文件
jsonutils_2">全局配置 app.json(utils目录下)
pages字段:描述当前小程序所有的页面路径
json"> "pages":[
"pages/index/index",
"pages/logs/logs"
],
//对应的是文件夹pages页面的两个文件,注意,文件没有后缀名
-
新增一个页面
json"> "pages":[ "pages/index/index", "pages/logs/logs", "pages/demo01/demo01" ], //或者可以像创建文件一样一级一级的创建即可:一个文件夹+4个子文件.js .json .wxml .wxss
-
设置默认显示界面是什么 :
//想让谁是第一个显示的界面就放在最上面
window字段:定义小程序所有页面的顶部背景颜色
-
json">"window":{ "backgroundTextStyle":"light",//下拉loading的样式,值为dark或light "navigationBarBackgroundColor": "#fff", //导航栏背景颜色 "navigationBarTitleText": "Weixin",//导航栏标题 "navigationBarTextStyle":"black",//导航栏文字颜色:颜色只能是黑色或者白色,不能是其他 "enablePullDownRefresh":true, //开启全局下拉刷新,默认值是false "backgroundColor":"#ABC" //loading那一小块区域的背景颜色,整体窗口的背景颜色应该是在wxss中设置的,支支持#xxx了 },
tabbar字段:选项卡字段
-
json">"tabBar": { "list": [{ "pagePath": "pagePath", //页面路径 "text": "text", //页面标题 "iconPath": "iconPath", //未选择图标路径 "selectedIconPath": "selectedIconPath" //已经选中的图标路径 }], //list数组至少包含两项,最多5项 "color":"#0094ff",//只支持十六进制,没有选中的时候选项卡上文字的颜色 "selectedColor":"#ff9400",//只支持十六进制,选中的情况下文字的颜色 "backgroundColor":"#ff0000",//只支持十六进制,选项卡背景颜色设置 "position":"bottom" //默认时下面,值只有两个--top和bottom,当在上面的时候默认图标icon不再显示 },
-
图片放到与page同级的目录下:粘贴复制即可
json">{
"pages":[
"pages/demo01/demo01",
"pages/index/index",
"pages/img/img",
"pages/mine/mine",
"pages/search/search",
"pages/logs/logs",
"pages/demo03/demo03"
],
"window":{
"backgroundTextStyle":"dark",
"navigationBarBackgroundColor": "#0099ff",
"navigationBarTitleText": "练习一",
"navigationBarTextStyle":"white",
"enablePullDownRefresh":true,
"backgroundColor":"#abc"
},
"tabBar": {
"list": [{
"pagePath": "pages/index/index",
"text": "首页",
"iconPath": "icon/1.png",
"selectedIconPath": "icon/5.png"
},
{
"pagePath": "pages/img/img",
"text": "图片页",
"iconPath": "icon/2.png",
"selectedIconPath": "icon/6.png"
},
{
"pagePath": "pages/mine/mine",
"text": "个人页",
"iconPath": "icon/3.png",
"selectedIconPath": "icon/7.png"
},
{
"pagePath": "pages/search/search",
"text": "搜索页",
"iconPath": "icon/4.png",
"selectedIconPath": "icon/8.png"
}
],
"backgroundColor":"#009468",
"color": "#112233",
"selectedColor": "#556677"
},
"style": "v2",
"sitemapLocation": "sitemap.json"
}
json_126">页面配置 page.json
- 为每一个页面设置不同的标题,导航栏颜色等window里面的属性