🚀
头像

默永


人生就像骑单车,想保持平衡就得往前走。

微信小程序 — 全局配置项

2022-11-15 09:00:49 124 💗 0 @默永

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

属性名类型默认值说明
navigationBarTitleText
String字符串导航栏标题文字内容
navigationBarBackgroundColorHexColor#000000导航栏背景颜色
navigationBarTextStyleStringwhite导航栏标题颜色,仅支持black/white
backgroundColorHexColor#ffffff下拉窗口的背景色
backgroundTextStyleStringdark下拉loading的样式,仅支持dark/light
enablePullDownRefreshBooleanfalse是否全局开启下拉刷新
onReachBottomDistanceNumber50页面上拉触底事件触发时距页面底部的距离,单位为px
app.json -> window ->

"window": {
  "navigationBarTitleText": "Weixin",
  "navigationBarBackgroundColor": "#fff",
  "navigationBarTextStyle": "black",
  "backgroundColor": "#ffffff",
  "backgroundTextStyle": "light",
  "enablePullDownRefresh": false,
  "onReachBottomDistance": 0
}

2. 全局配置 - tabBar导航栏

属性类型必填默认值描述
positionStringbottomtabBar的位置,仅支持bottom/top
borderStyleStringblacktabBar上边框的颜色,仅支持black/white
colorHexColortab上文字的默认(未选中)颜色
selectedColorHexColortab上的文字选中时的颜色
backgroundColorHexColortabBar的背景色
listArray
tab页签的列表,最少2个、最多5个tab

list中的配置选项

属性类型必填描述
pagePathString页面路径,页面必须在pages中预先定义
textStringtab上显示的文字
iconPathString未选中时的图标路径;当position为top时,不显示icon
selectedIconPathString选中时的图标路径;当position为top时,不显示icon
"tabBar": {
  "list": [
    {
      "pagePath": "pagePath",
      "text": "text",
      "iconPath": "iconPath",
      "selectedIconPath": "selectedIconPath"
    }
  ]
},

3. 页面中常用的配置项

{
  "usingComponents": {},
  "navigationBarTitleText": "Weixin",
  "navigationBarBackgroundColor": "#fff",
  "navigationBarTextStyle": "black",
  "backgroundColor": "#fff",
  "backgroundTextStyle": "light",
  "enablePullDownRefresh": true,
  "onReachBottomDistance": 50
},
    目录导航