微信小程序笔记 全局配置 pages、window、tabBar

关于全局配置可以在微信官方文档查到:
微信小程序笔记 全局配置 pages、window、tabBar_第1张图片
全局配置在app.json中设置。

一、pages
略。

二、window
window的部分属性如下:
微信小程序笔记 全局配置 pages、window、tabBar_第2张图片
一般enablePullDownRefresh(是否开启全局的下拉刷新)不会在app.json中设置,除非所有的页面都有下拉刷新的功能。

三、tabBar
tabBar的部分属性如下:
微信小程序笔记 全局配置 pages、window、tabBar_第3张图片
注意,如果tabBar的list中如果没有路径"pages/index/index",则会报错或tabBar无法显示。
示例:
app.json:

{
  "pages": [
    "pages/index/index",
    "pages/test/test",
    
    "pages/home/home",
    "pages/discover/discover",
    "pages/mine/mine"
  ],
  "window": {
    "navigationBarBackgroundColor": "#ffa727",
    "navigationBarTitleText": "摊易选",
    "navigationBarTextStyle": "black",

    "enablePullDownRefresh": true,
    "backgroundColor": "#e9e9e9",
    "backgroundTextStyle": "dark"
  },
  "tabBar":{
    "color":"#dcdcdc",
    "selectedColor":"#2c2c2c",
    "backgroundColor":"#ffa727",
    "list":[
      {
        "pagePath":"pages/index/index",
        "text":"首页",
        "iconPath":"images/home.png",
        "selectedIconPath":"images/homeActive.png"
      },
      {
        "pagePath":"pages/discover/discover",
        "text":"发现",
        "iconPath":"images/discover.png",
        "selectedIconPath":"images/discoverActive.png"
      },
      {
        "pagePath":"pages/mine/mine",
        "text":"我的",
        "iconPath":"images/mine.png",
        "selectedIconPath":"images/mineActive.png"
      }
    ]
  },

  "sitemapLocation": "sitemap.json",
  "style": "v2"
}

前端效果图:
微信小程序笔记 全局配置 pages、window、tabBar_第4张图片

你可能感兴趣的:(微信小程序,小程序)