【微信小程序】page.json配置-tabBar底部栏

在微信小程序中,page.json 文件不仅用于配置单个页面的样式和其他属性,还可以用于配置底部导航栏(tabBar)。通过在 page.json 文件中配置 tabBar,可以实现小程序底部导航栏的自定义,包括导航栏的样式、图标和文字等。本文将详细介绍如何在 page.json 文件中配置底部导航栏,并提供一些最佳实践。

1. tabBar 基本配置

page.json 文件中配置 tabBar 时,需要在文件中添加 tabBar 属性,并指定相应的配置项。以下是详细的配置步骤和示例:

1.1 配置 tabBar 基本属性

page.json 文件中添加 tabBar 属性,并配置基本属性:

{
   
  "tabBar": {
   
    "color": "#7A7E83",               // 默认字体颜色
    "selectedColor": "#1296db",       // 选中字体颜色
    "borderStyle": "black",           // tabBar 上边框的颜色,仅支持 black / white
    "list": [
      {
   
        "pagePath": "pages/index/index",
        "text": "首页",
        "iconPath": "/images/home.png",
        "selectedIconPath": "/images/home-active.png"
      },
      {
   
        "pagePath": "pages/logs/logs",
        "text": "日志",
        "iconPath": "/images/logs.png",
        "selectedIconPath": "/images/logs-active.png"
      }
    ]
  }
}

2. 配置 tabBar 详细属性

除了基本属性外,tabBar 还支持更多详细的配置项,包括背景色、位置、自定义样式等。

2.1 背景色和位置

配置 tabBar 的背景色和位置:

{
   
  "tabBar": {
   
    "color": "#7A7E83",
    "selectedColor": "#1296db",
    "borderStyle": "black",
    "backgroundColor": "#FFFFFF",     // tabBar 背景色
    "position": "bottom",             // tabBar 位置,支持 bottom / top
    "list": [
      {
   
        "pagePath": "pages/index/index",
        "text":
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值