小程序項目的全局配置

全局配置

window

用於設置小程序的狀態欄、導航條、標題、窗口背景色。json

  • navigationBarBackgroundColor HexColor #000000 導航欄背景顏色,如 #000000小程序

  • navigationBarTextStyle String white 導航欄標題顏色,僅支持 black / white微信小程序

  • navigationBarTitleText String 導航欄標題文字內容數組

    <p style="color: #f60;">wepy框架裏面不能直接在app裏面設置,須要在使用的頁面裏面設置,不然不會顯示</p>微信

  • navigationStyle String default 導航欄樣式,僅支持如下值:網絡

    • default 默認樣式
    • custom 自定義導航欄,只保留右上角膠囊按鈕。
  • backgroundColor HexColor #ffffff 窗口的背景色app

    <p style="color: #f60;">當咱們在微信小程序`json`中設置`backgroundColor` 時,實際在電腦的模擬器中根本看不到效果。 這是由於 `backgroundColor` 指的窗體背景顏色,而不是頁面的背景顏色,即窗體下拉刷新或上拉加載時露出的背景。在電腦的模擬器中是看不到這個動做的,因此會讓人誤覺得這個配置是無效的。</p>框架

  • backgroundTextStyle String dark 下拉 loading 的樣式,僅支持 dark / lightpost

  • backgroundColorTop String #ffffff 頂部窗口的背景色,僅 iOS 支持 微信客戶端 6.5.16spa

  • backgroundColorBottom String #ffffff 底部窗口的背景色,僅 iOS 支持 微信客戶端 6.5.16

  • enablePullDownRefresh Boolean false 是否開啓當前頁面的下拉刷新。 詳見 Page.onPullDownRefresh

  • onReachBottomDistance Number 50 頁面上拉觸底事件觸發時距頁面底部距離,單位爲px。 詳見 Page.onReachBottom

  • pageOrientation String portrait 屏幕旋轉設置,僅支持 auto / portrait 詳見 響應顯示區域變化 微信客戶端 6.7.3

用例:

window: {
    // 導航欄背景顏色
    "navigationBarBackgroundColor": "#FF6666",
    // 導航欄標題顏色,僅支持 black / white
    "navigationBarTextStyle": "white",
    // 航欄樣式,僅支持如下值: default, custom 自定義導航欄,只保留右上角膠囊按鈕
    "navigationStyle": "default",
    // 窗口的背景色
    "backgroundColor": "#e5e5e5",
    // 下拉 loading 的樣式,僅支持 dark / light
    "backgroundTextStyle": "dark",
    // 屏幕旋轉設置,僅支持 auto / portrait
    "pageOrientation": "portrait",
}

Tabbar

若是小程序是一個多tab應用(客戶端窗口的底部或頂部有 tab 欄能夠切換頁面),能夠經過tabBar配置項指定tab欄的表現,以及tab切換時顯示的對應頁面。

  • color tab上的文字默認顏色,僅支持十六進制顏色
  • selectedColor tab上的文字選中時的顏色,僅支持十六進制顏色
  • backgroundColor tab的背景色,僅支持十六進制顏色
  • borderStyle tabbar上邊框的顏色, 僅支持 black / white
  • list tab的列表,詳見 list 屬性說明,最少2個、最多5個 tab
  • position tabBar的位置,僅支持 bottom / top

list 接受一個數組,只能配置最少2個、最多5個 tab。tab 按數組的順序排序,每一個項都是一個對象,其屬性值以下:

  • pagePath 頁面路徑,必須在 pages 中先定義
  • text tab上按鈕文字
  • iconPath 圖片路徑,icon 大小限制爲40kb,建議尺寸爲 81px * 81px,不支持網絡圖片。當 postion 爲 top 時,不顯示 icon。
  • selectedIconPath 選中時的圖片路徑,icon 大小限制爲40kb,建議尺寸爲 81px * 81px,不支持網絡圖片。當 postion 爲 top 時,不顯示 icon。

用例:

tabBar: {
    color: '#666666',
    selectedColor: '#ff6600',
    position: 'bottom',
    backgroundColor: '#fff',
    borderStyle: 'black',
    list: [
      {
        pagePath: 'pages/home/index',
        text: '首頁',
        iconPath: 'assets/img/icon-1.png',
        selectedIconPath: 'assets/img/icon-1-selected.png'
      },
      {
        pagePath: 'pages/search/index',
        text: '搜索',
        iconPath: 'assets/img/icon-2.png',
        selectedIconPath: 'assets/img/icon-2-selected.png'
      },
      {
        pagePath: 'pages/sell/index',
        text: '排行榜',
        iconPath: 'assets/img/icon-3.png',
        selectedIconPath: 'assets/img/icon-3-selected.png'
      },
      {
        pagePath: 'pages/spike/index',
        text: '搶購',
        iconPath: 'assets/img/icon-2.png',
        selectedIconPath: 'assets/img/icon-2-selected.png'
      },
      {
        pagePath: 'pages/profile/index',
        text: '個人',
        iconPath: 'assets/img/icon-5.png',
        selectedIconPath: 'assets/img/icon-5-selected.png'
      }
    ]
}
相關文章
相關標籤/搜索