微信小程序入門: 導航欄樣式、tabBar導航欄

導航欄樣式設置

小程序的導航欄樣式在app.json中定義。json

這裏設置導航,背景黑色,文字白色,文字內容測試小程序小程序

app.json內容:數組

{
  "pages":[
    "pages/index/index",
    "pages/login/login",
    "pages/logs/logs"
  ],
  "window":{
    "backgroundTextStyle":"red",
    "navigationBarBackgroundColor": "#000",
    "navigationBarTitleText": "測試小程序",
    "navigationBarTextStyle":"#fff"
  }
}

window中的樣式說明:app

clipboard.png

效果:測試

clipboard.png

tabBar導航欄

tabBar挺好的,能夠放置於頂部或者底部,用於不一樣功能頁面的切換。spa

tabBar一樣在app.json中進行定義,看一下我在app.json中對tabBar的相關定義:code

"tabBar": {
    "selectedColor": "#1296db",
    "list": [{
      "pagePath": "pages/index/index",
      "text": "首頁",
      "iconPath": "images/ico-home.png",
      "selectedIconPath": "images/ico-home-d.png"
    },{
      "pagePath": "pages/setting/setting",
      "text": "設置",
      "iconPath": "images/ico-setting.png",
      "selectedIconPath": "images/ico-setting-d.png"
    },{
      "pagePath": "pages/help/help",
      "text": "幫助",
      "iconPath": "images/ico-help.png",
      "selectedIconPath": "images/ico-help-d.png"
    }]
  }

效果:排序

clipboard.png

tabBar相關屬性定義說明:ip

clipboard.png

tabBar list定義說明:it

clipboard.png

tabBar 是一個數組,只能配置最少2個、最多5個 tab,tab 按數組的順序排序。

相關文章
相關標籤/搜索