【微信小程序】tabBar全局配置

一、tabBar的组成成分

属性 类型 必填 默认值 描述
color HexColor tab 上的文字默认颜色,仅支持十六进制颜色
selectedColor HexColor tab 上的文字选中时的颜色,仅支持十六进制颜色
backgroundColor HexColor tab 的背景色,仅支持十六进制颜色
borderStyle string black tabbar 上边框的颜色, 仅支持 black / white
list Array tab 的列表,详见 list 属性说明,最少 2 个、最多 5 个 tab
position string bottom tabBar 的位置,仅支持 bottom / top

二、list属性

属性 类型 必填 说明
pagePath string 页面路径,必须在 pages 中先定义
text string tab 上按钮文字
iconPath string 图片路径,icon 大小限制为 40kb,建议尺寸为 81px * 81px,不支持网络图片。 positiontop 时,不显示 icon。
selectedIconPath string 选中时的图片路径,icon 大小限制为 40kb,建议尺寸为 81px * 81px,不支持网络图片。 positiontop 时,不显示 icon。

更多信息:全局配置 | 微信开放文档

三、示例

复制代码
"tabBar": {
      "selectedColor": "#f3514f",
      "color": "#666",
      "backgroundColor": "#efefef",
      "borderStyle":"black",
      "position":"bottom",
      "list": [
          {
              "text": "首页",
              "pagePath": "pages/index/index",
              "iconPath": "/image/first_page.png",
              "selectedIconPath": "/image/active_fp.png"
          },
          {
            "text": "分类",
            "pagePath": "pages/classify/classify",
            "iconPath": "/image/classify.png",
            "selectedIconPath": "/image/active_classify.png"
        },
        {
            "text": "购物车",
            "pagePath": "pages/car/car",
            "iconPath": "/image/buy_car.png",
            "selectedIconPath": "/image/active_car.png"
        },
        {
            "text": "我的",
            "pagePath": "pages/me/me",
            "iconPath": "/image/me.png",
            "selectedIconPath": "/image/active_me.png"
        }
      ]
  },
相关推荐
人工智能的苟富贵3 小时前
微信小程序直传阿里云 OSS 实践指南(V4 签名 · 秒传支持 · 高性能封装)
阿里云·微信小程序·小程序
时之彼岸Φ4 小时前
Fiddler+Yakit实现手机流量抓包和小程序抓包
智能手机·小程序·fiddler
换日线°4 小时前
微信小程序根据图片生成背景颜色有效果图
微信小程序
suncentwl5 小时前
为什么选择有版权的答题pk小程序
小程序·答题小程序·答题pk
小旋风012346 小时前
uniapp自定义头部(兼容微信小程序(胶囊和状态栏),兼容h5)
微信小程序·uni-app·notepad++
GalenZhang8888 小时前
Java生成微信小程序码及小程序短链接
java·微信小程序·小程序
浮桥9 小时前
uniapp -- 实现微信小程序、app、H5端视频上传
微信小程序·uni-app·音视频
说私域11 小时前
从大众传媒到数字生态:开源AI智能名片链动2+1模式S2B2C商城小程序驱动的营销革命
人工智能·小程序·开源·零售
换日线°11 小时前
微信小程序连续多个特殊字符自动换行解决方法
微信小程序
海拥12 小时前
《用Cursor和AI绘画24小时开发壁纸小程序》详细开发实录
微信小程序·cursor