源码网商城,靠谱的源码在线交易网站 我的订单 购物车 帮助

源码网商城

微信小程序tabBar用法实例详解

  • 时间:2020-08-25 00:06 编辑: 来源: 阅读:
  • 扫一扫,手机访问
摘要:微信小程序tabBar用法实例详解
本文实例讲述了微信小程序tabBar用法。分享给大家供大家参考,具体如下: [b]1、效果展示[/b] [img]http://files.jb51.net/file_images/article/201712/2017124101908579.gif?2017114101925[/img] [b]2、原理[/b]:在app.json中配置tabBar属性
{
 "pages": [
  "index",
  "picDisplay"
 ],
 "window": {
  "navigationBarBackgroundColor": "#ffffff",
  "navigationBarTextStyle": "black",
  "navigationBarTitleText": "首页",
  "backgroundColor": "#eeeeee",
  "backgroundTextStyle": "light",
  "enablePullDownRefresh": false
 },
 "tabBar": {
  "color":"#666666",
  "selectedColor":"#06bd04",
  "list": [{
   "pagePath": "index",
   "text": "首页",
   "iconPath": "images/index.png",
   "selectedIconPath": "images/indexHL.png"
  },{
   "pagePath": "picDisplay",
   "text": "图片展示",
   "iconPath": "images/picDisplay.png",
   "selectedIconPath": "images/picDisplayHL.png"
  }]
 }
}

[b]3、关键代码[/b]
"tabBar": {
  "color":"#666666",
  "selectedColor":"#06bd04",
  "list": [{
   "pagePath": "index",
   "text": "首页",
   "iconPath": "images/index.png",
   "selectedIconPath": "images/indexHL.png"
  },{
   "pagePath": "picDisplay",
   "text": "图片展示",
   "iconPath": "images/picDisplay.png",
   "selectedIconPath": "images/picDisplayHL.png"
  }]
 }

[b]4、操作方法[/b] 新建一个项目,打开app.json文件,将关键代码复制到"window":{},后面,注意window的大括号前加逗号,如下图 [img]http://files.jb51.net/file_images/article/201712/2017124104350303.png?2017114104413[/img] 配置tabBar属性值
"tabBar": {
  //设置tabBar文字默认颜色
  "color":"#666666",
  //设置tabBar文字被选中是的颜色
  "selectedColor":"#06bd04",
  //tab列表,数组类型,改数组内至少要有两个但不大于5个的tab对象
  "list": [{
   //设置tab跳转页面链接
   "pagePath": "index",
   //设置tab上的文字
   "text": "首页",
   //设置tab上的默认图标
   "iconPath": "images/index.png",
   //设置tab被选中时的图标
   "selectedIconPath": "images/indexHL.png"
  },{
   "pagePath": "picDisplay",
   "text": "图片展示",
   "iconPath": "images/picDisplay.png",
   "selectedIconPath": "images/picDisplayHL.png"
  }]
 }

[b]tabBar的5种常用属性与配置说明:[/b] 1) color:未选择字体颜色 2) selectedColor:选择字体颜色 3) borderStyle:tabbar上方线的颜色white(仅支持白色和黑色) 4) backgroundColor:tabbar背景颜色 5) list:设置rab列表项(最少2个,最多5个tab)。 [b]另外,list作为数组属性,其每一项又是一个对象,list可以设置4种属性:[/b] ① text:设置tab上的文字 ② iconPath:设置tab处于未激活状态时显示的图片路径。 ③ selectedIconPath:设置tab处于激活状态时的图片路径(iconPath与selectedIconPath图片大小限制都是40KB) ④ pagePath:设置触按tab时的跳转页面路径(该页面必须在pages中进行了配置[b]5、完整实例代码[/b]点击此处[url=http://xiazai.jb51.net/201712/yuanma/wx-tabBar-demo(jb51.net).rar][b]本站下载[/b][/url]。 此外,微信小程序开发软件下载地址如下: [url=https://mp.weixin.qq.com/debug/wxadoc/dev/devtools/download.html?t=201714]https://mp.weixin.qq.com/debug/wxadoc/dev/devtools/download.html?t=201714[/url] 希望本文所述对大家微信小程序开发有所帮助。
  • 全部评论(0)
联系客服
客服电话:
400-000-3129
微信版

扫一扫进微信版
返回顶部