实现小程序底部导航tabBar

一般在app和电商网站中底部的切换高亮显示是非常的常见的

现在来实现一下:
在这里插入图片描述
一、首先先找到文件目录下的
在这里插入图片描述
二、在这个app.josn文件中写入

{
  "pages": [
    "pages/index/index",
    "pages/message/message",
    "pages/profile/profile",
    "pages/contact/contact"
  ],
  "window": {
    "backgroundTextStyle": "light",
    "navigationBarBackgroundColor": "#fff",
    "navigationBarTitleText": "本地生活项目",
    "navigationBarTextStyle": "black"
  },
  "tabBar": {
    "color": "#000000",
    "selectedColor": "#ff0000",
    "borderStyle": "black",
    "list": [
      {
        "selectedIconPath": "./tabs/home-active.png",
        "iconPath": "./tabs/home.png",
        "pagePath": "pages/index/index",
        "text": "首页"
      },
      {
        "selectedIconPath": "./tabs/message-active.png",
        "iconPath": "./tabs/message.png",
        "pagePath": "pages/message/message",
        "text": "信息"
      },
      {
        "selectedIconPath": "./tabs/profile-active.png",
        "iconPath": "./tabs/profile.png",
        "pagePath": "pages/profile/profile",
        "text": "我的"
      },
      {
        "selectedIconPath": "./tabs/contact-active.png",
        "iconPath": "./tabs/contact.png",
        "pagePath": "pages/contact/contact",
        "text": "联系我们"
      }
    ]
  },
  "sitemapLocation": "sitemap1.json"
}

三、来说一下意思

"pages": [
    "pages/index/index",
    "pages/message/message",
    "pages/profile/profile",
    "pages/contact/contact"
  ],  

就是在pages目录下创建注册index文件夹文件下就会自动生成4个文件js、json、wxml、wxss

下面在来说一下tabbar数组下的属性

  • tabBar 这个是底部的导航配置属性
  • color 未选中时底部导航文字的颜色
  • selectedColor 点击选中时底部导航文字的颜色
  • borderStyle 底部导航边框的样色(这里如果没有写入样式 会导致 导航框上边框会出现默认的浅灰色线条)
  • list 导航配置数组
  • iconPath 未选中时图标路径
  • selectedIconPath 选中时图标路径 也就是高亮的效果
  • text 导航图标下方文字
  • pagePath 页面访问地址 也就是点击要去的地方
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值