微信小程序------导航栏样式、tabBar导航栏

一:导航栏样式设置

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

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

app.json内容:

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

window中的样式说明:

属性类型默认值描述
navigationBarBackgroundColorHexColor000000 导航栏背景颜色,如”#000000” 
navigationBarTextStyleStringwhite导航栏标题颜色,仅支持 black/white
navigationBarTitleTextString 导航栏标题文字内容
backgroundColorHexColor#ffffff窗口的背景色
backgroundTextStyleStringdark下拉背景字体、loading 图的样式,仅支持 dark/light
enablePullDownRefreshBooleanfalse是否开启下拉刷新

效果:

 1 "tabBar": {
 2     "selectedColor": "#1296db",
 3     "list": [{
 4       "pagePath": "pages/index/index",
 5       "text": "首页",
 6       "iconPath": "images/ico-home.png",//找到图片在哪个文件夹(写路径)
 7       "selectedIconPath": "images/ico-home-d.png"
 8     },{
 9       "pagePath": "pages/setting/setting",
10       "text": "设置",
11       "iconPath": "images/ico-setting.png",//找到图片在那个文件夹(写路径)
12       "selectedIconPath": "images/ico-setting-d.png"
13     },{
14       "pagePath": "pages/help/help",
15       "text": "帮助",
16       "iconPath": "images/ico-help.png",//找到图片在那个文件夹(写路径)
17       "selectedIconPath": "images/ico-help-d.png"
18     }]
19   }

 注意:两个图标是有两个路径,第一个是当前默认图标的路径("iconPath");第二个是被选中之后图标路径("selectedIconPath"),停留在那个页面,图标变色。

二:tabBar导航栏

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

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

效果:

tabBar相关属性定义说明:

属性类型必填默认值描述
colorHexColor tab 上的文字默认颜色
selectedColorHexColor tab 上的文字选中时的颜色
backgroundColorHexColor tab 的背景色
borderStyleStringblacktabbar上边框的颜色, 仅支持 black/white
listArray tab 的列表,详见 list 属性说明,最少2个、最多5个 tab
positionStringbottom可选值 bottom、top

tabBar list定义说明:

属性类型必填说明
pagePathString页面路径,必须在 pages 中先定义
textStringtab 上按钮文字
iconPathString图片路径,icon 大小限制为40kb,建议尺寸为 81px * 81px
selectedIconPathString选中时的图片路径,icon 大小限制为40kb,建议尺寸为 81px * 81px

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

转载于:https://www.cnblogs.com/yuyu1993/p/8274440.html

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值