小程序全局配置

小程序根目录下的app.json文件是小程序的全局配置文件。常用配置项如下:

1.pages

        记录当前小程序所有页面的存放路径

2.window

        全局设置小程序窗口的外观

3.tabBar

        设置小程序底部的tarBar效果

4.style

是否启用新版的组件样式

2.了解window节点常用的配置项

属性名

类型

默认值

说明

navigationBarTitleText

String

字符串

导航栏标题文字内容

navigationBarBackgroundColor

HexColor

#000000

导航栏背景颜色,如 #000000

navigationBarTextStyle

String

white

导航栏标题颜色,仅支持 

black / white

backgroundColor

HexColor

#ffffff

窗口的背景色

backgroundTextStyle

String

dark

下拉 loading 的样式,仅支持 

dark / light

enablePullDownRefresh

Boolean

false

是否全局开启下拉刷新

onReachBottomDistance

Number

50

页面上拉触底事件触发时距

页面底部距离,单位为px

  "window":{
    "backgroundTextStyle":"light",
    "navigationBarBackgroundColor": "#bfa",
    "navigationBarTitleText": "wx",
    "navigationBarTextStyle":"black",
    "backgroundColor": "#bfa",
    "enablePullDownRefresh": true
 
  },

 

3.tabBar

        tabBar是移动端应用常见的页面效果,用于实现多页面的快速切换(tabBar中只能由2-5个tab页签,只有底部tabBar才会显示icon图标)

tabBar6个组成部分

        

tabBar节点的配置项

属性

类型

必填

默认值

描述

position

String

bottom

tabBar 的位置,仅支持 

bottom/top

borderStyle

String

black

tabBar 上边框的颜色,仅支持 

black/white

color

HexColor

tab 上文字的默认(未选中)

颜色

selectedColor

HexColor

tab 上的文字选中时的颜色

backgroundColor

HexColor

tabBar 的背景色

list

Array

tab 页签的列表,

最少 2 个、最多 5 个 tab

 

 "tabBar": {
    "list":[
      {
        "pagePath": "pages/home/home",
        "text": "主页",
        "iconPath": "/images/home.png",
        "selectedIconPath": "/images/home-active.png"
      },
      {
        "pagePath": "pages/message/message",
        "text": "消息",
        "iconPath": "/images/message.png",
        "selectedIconPath": "/images/message-active.png"
      },
      {
        "pagePath": "pages/contact/contact",
        "text": "联系我们",
        "iconPath": "/images/contact.png",
        "selectedIconPath": "/images/contact-active.png"
      }
    ]
  },

 每个tab项的配置选项

属性

类型

必填

描述

pagePath

String

页面路径,页面必须在 pages 中预先定义

text

String

tab 上显示的文字

iconPath

String

未选中时的图标路径;当 postion 为 top 时,不显示 icon

selectedIconPath

String

选中时的图标路径;当 postion 为 top 时,不显示 icon

 

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值