uniapp项目-配置pages.json

文章详细介绍了如何在微信小程序中配置tabBar的选中颜色、底部导航栏的各个选项(包括页面路径、文本和图标),以及如何设置分包、全局样式和单个页面的样式,如导航栏标题、背景等。

1.配置tabBar

说明:selectedcolor是选中的颜色;lists底部导航栏的每个导航项的列表,

  • "pagePath":导航项关联的页面路径。
  • "text":导航项显示的文本内容。
  • "iconPath":导航项默认状态下的图标路径。
  • "selectedIconPath":导航项选中状态下的图标路径。
    "tabBar" : {
        "selectedColor" : "#C00000",
        "list" : [
            {
                "pagePath" : "pages/home/home",
                "text" : "首页",
                "iconPath" : "static/tab_icons/home.png",
                "selectedIconPath" : "static/tab_icons/home-active.png"
            },
            {
                "pagePath" : "pages/cate/cate",
                "text" : "分类",
                "iconPath" : "static/tab_icons/cate.png",
                "selectedIconPath" : "static/tab_icons/cate-active.png"
            },
            {
                "pagePath" : "pages/cart/cart",
                "text" : "购物车",
                "iconPath" : "static/tab_icons/cart.png",
                "selectedIconPath" : "static/tab_icons/cart-active.png"
            },
            {
                "pagePath" : "pages/my/my",
                "text" : "我的",
                "iconPath" : "static/tab_icons/my.png",
                "selectedIconPath" : "static/tab_icons/my-active.png"
            }
        ]
    },

 2.配置分包

说明:

  • "subPackages":子包的配置列表。
  • "root":子包的根目录,表示该子包的页面都位于此目录下。
  • "pages":子包中的页面列表。
    "subPackages" : [
        {
            "root" : "subpkg",
            "pages" : [
                {
                    "path" : "goods-detail/goods-detail",
                    "style" : {
                        "navigationBarTitleText" : "",
                        "enablePullDownRefresh" : false
                    }
                },
                {
                    "path" : "goods_list/goods_list",
                    "style" : {
                        "navigationBarTitleText" : "",
                        "enablePullDownRefresh" : true,
                        "onReachBottomDistance": 150,
                        "backgroundColor": "#F8F8F8"
                    }
                },
                {
                    "path" : "search/search",
                    "style" : {
                        "navigationBarTitleText" : "",
                        "enablePullDownRefresh" : false
                    }
                }
            ]
        }
    ],

3.配置全局样式

说明:

  • "navigationBarTextStyle":导航栏标题的文字颜色。
  • "navigationBarTitleText":导航栏标题的文字内容。
  • "navigationBarBackgroundColor":导航栏的背景色。
  • "backgroundColor":页面的默认背景色。
    "globalStyle" : {
        "navigationBarTextStyle" : "white",
        "navigationBarTitleText" : "FOREVER",
        "navigationBarBackgroundColor" : "#C00000",
        "backgroundColor" : "#F8F8F8",
        "app-plus" : {
            "background" : "#efeff4"
        }
    },

4.配置page

说明:

  • "pages":页面的配置列表。
  • "path":页面的路径,用于指定页面所对应的文件位置。
  • "style":页面的样式配置,用于定义每个页面的特定样式。
    "pages" : [
      {
          "path" : "pages/home/home",
          "style" : {
              "navigationBarTitleText" : "",
              "enablePullDownRefresh" : false
          }
      },
        {
            "path" : "pages/cate/cate",
            "style" : {
                "navigationBarTitleText" : "",
                "enablePullDownRefresh" : false
            }
        },
        {
            "path" : "pages/cart/cart",
            "style" : {
                "navigationBarTitleText" : "",
                "enablePullDownRefresh" : false
            }
        },
        {
            "path" : "pages/my/my",
            "style" : {
                "navigationBarTitleText" : "",
                "enablePullDownRefresh" : false
            }
        }
    ],

 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

FOREVER-Q

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值