【微信小程序】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"
        }
      ]
  },
相关推荐
Uyker9 小时前
从零开始制作小程序简单概述
前端·微信小程序·小程序
打小就很皮...16 小时前
HBuilder 发行Android(apk包)全流程指南
前端·javascript·微信小程序
说私域19 小时前
定制开发开源AI智能名片驱动下的海报工厂S2B2C商城小程序运营策略——基于社群口碑传播与子市场细分的实证研究
人工智能·小程序·开源·零售
说私域1 天前
内容力重塑品牌增长:开源AI大模型驱动下的智能名片与S2B2C商城赋能抖音生态种草范式
人工智能·小程序·开源·零售
前端缘梦1 天前
微信小程序登录方案实践-从账号体系到用户信息存储
前端·微信小程序
coding随想1 天前
2025年小程序开发全解析:技术储备、行业趋势与实战案例
微信小程序
Nueuis2 天前
微信小程序前端面经
前端·微信小程序·小程序
轩1152 天前
实现仿中国婚博会微信小程序
微信小程序·小程序
知否技术2 天前
2025微信小程序开发实战教程(一)
前端·微信小程序
喝牛奶的小蜜蜂2 天前
个人小程序:不懂后台,如何做数据交互
前端·微信小程序·小程序·云开发