微信小程序底部导航栏

本文详细介绍如何在微信小程序中实现底部导航栏功能,包括设置导航颜色、图标及页面跳转等关键步骤。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

“花树得晴红欲染,远山过雨青如滴”

最近自己在研究微信小程序,几乎每个程序都会有导航栏,或在顶部,或在底部。于是我简单做了一个导航栏在底部的程序。

正文

这里就直接贴代码了:

在app.json里面添加tabBar

"tabBar": {
    "color": "#a9b7b7",
    "selectedColor": "#11cd6e",
    "borderStyle": "white",
    "list": [
      {
        "selectedIconPath": "images/home_selected.png",
        "iconPath": "images/home.png",
        "pagePath": "pages/index/index",
        "text": "首页"
      },
      {
        "selectedIconPath": "images/add_selected.png",
        "iconPath": "images/add.png",
        "pagePath": "pages/deploy/deploy",
        "text": "发布"
      },
      {
        "selectedIconPath": "images/account_selected.png",
        "iconPath": "images/account.png",
        "pagePath": "pages/account/account",
        "text": "我的"
      }
    ]
  }

解释一下属性的作用:

tabBar  指底部的 导航配置属性
color  未选择时 底部导航文字的颜色
selectedColor  选择时 底部导航文字的颜色
borderStyle  底部导航边框的样色
list   导航配置数组
selectedIconPath 选中时 图标路径
iconPath 未选择时 图标路径
pagePath 页面访问地址
text  导航图标下方文字

具体请看官方文档:微信官方文档:Tabbar

效果是这样的:
在这里插入图片描述

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值