03.全局配置app.json 和 局部配置xx.json

{
  "pages": [
    "pages/index/index",
    "pages/logs/logs"
  ],
  "window": {
    "navigationBarBackgroundColor": "#ffffff",
    "navigationBarTextStyle": "black",
    "navigationBarTitleText": "小程序",
    "backgroundColor": "#eeeeee",
    "backgroundTextStyle": "light",
    "enablePullDownRefresh": true
  },
  "tabBar": {
    "list": [
      {
        "pagePath": "pages/index/index",
        "text": "首页",
        "iconPath": "images/home.png",
        "selectedIconPath": "images/home-selected.png"
      },
      {
        "pagePath": "pages/logs/logs",
        "text": "日志",
        "iconPath": "images/search.png",
        "selectedIconPath": "images/search-selected.png"
      }
    ]
  }
}

全局配置

pages

页面的路径配置,index代表了index.js、index.json、index.wxml、index.wxss,所以pages/index下的文件必须都是以index来命名,否则会报错

window

navigationBarBackgroundColor

导航条的背景颜色,仅支持16进制。

navigationBarTextStyle

导航条字体的颜色,仅支持white和black两种设置

navigationBarTitleText

导航条的字体

backgroundColor

下拉刷新时的背景颜色

backgroundTextStyle

下拉刷新时,圆圈的样式,仅支持light和dark两种设置

enablePullDownRefresh

是否开启下拉刷新,true或false

 

tabBar

list

list为一个数组,里面存储的是小程序底部的导航配置。

list至少需要2个json对象,最多能设置5个。

"pagePath": "pages/index/index", //页面路径
"text": "首页", //导航文字
"iconPath": "images/home.png", //没被选中的图片
"selectedIconPath": "images/home-selected.png" //被选中时的图片

需要注意的是,iconPath和selectedIconPath必须是本地图片,而且大小需要在40kb以内。建议尺寸为81x81

tabBar不常用的属性

"position" : "top",
"color" : "#000",
"selectedColor" : "#0066ff",
"backgroundColor" : "#eeeeee",
"borderStyle" : "black"

position

设置导航条的位置,值只有top和bottom,默认为bottom

需要注意的是,如果设置了position为top,则不支持图片icon

color

字体颜色,仅在position为top时生效

selectedColor

字体被选中时的颜色,仅在position为top时生效

backgroundColor

导航条的背景颜色,仅在position为top时生效

borderStyle

导航条下面的border,支持white和black。仅在position为top时生效

 

局部配置

app.json配置的是全局配置,我们可以看到每个pages下面的文件夹,都会有一个xx.json,这个是用来配置当前页的。

例子

需要注意的是,该json不用写window,而且优先级比app.json高

 

 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值