微信小程序入门: 导航栏样式、tabBar导航栏

导航栏样式设置

小程序的导航栏样式在app.json中定义。

这里设置导航,背景黑色,文字白色,文字内容测试小程序

app.json内容:

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

window中的样式说明:

微信小程序入门: 导航栏样式、tabBar导航栏

效果:

微信小程序入门: 导航栏样式、tabBar导航栏

tabBar导航栏

tabBar挺好的,可以放置于顶部或者底部,用于不同功能页面的切换。

tabBar同样在app.json中进行定义,看一下我在app.json中对tabBar的相关定义:

"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"
    }]
  }

效果:

微信小程序入门: 导航栏样式、tabBar导航栏

tabBar相关属性定义说明:

微信小程序入门: 导航栏样式、tabBar导航栏

tabBar list定义说明:

微信小程序入门: 导航栏样式、tabBar导航栏

tabBar 是一个数组,只能配置最少2个、最多5个 tab,tab 按数组的顺序排序。

相关推荐