微信小程序官方文档中TabBar

根据官方文档写的tabBar

  • 先创建文件夹

    • 图标:images文件夹下的icon
    • 先删除原来pages文件夹下的页面
    • 在重新在pages文件夹下新建四个页面,分别是:
      • chat:消息
      • doc:文档
      • home:首页
      • profile:我的
  • 目录结构:

在这里插入图片描述

  • 在每个页面文件夹下的index.json中,写入:"navigationBarTitleText": "",这样便于辨认tabBar之间的切换。

    • home页面中的index.json

      {
        "usingComponents": {},
        "navigationBarTitleText": "首页"
      }
      
    • chat页面中的index.json

      {
        "usingComponents": {},
        "navigationBarTitleText": "消息"
      }
      
    • doc页面中的index.json

      {
        "usingComponents": {},
        "navigationBarTitleText": "文档"
      }
      
    • profile页面中的index.json

      {
        "usingComponents": {},
        "navigationBarTitleText": "我的"
      }
      
  • 最后在app.json中配置tabBar

    {
      "pages":[
        "pages/home/index",
        "pages/doc/index",
        "pages/chat/index",
        "pages/profile/index"
      ],
      "window":{
        "backgroundTextStyle":"light",
        "navigationBarBackgroundColor": "#fff",
        "navigationBarTitleText": "Weixin",
        "navigationBarTextStyle":"black"
      },
      "tabBar": {
        "color": "#30c6c7",
        "selectedColor": "#fa8c57",
        "backgroundColor": "#f9f9f9",
        "borderStyle":"black",
        "position": "bottom",
        "list": [
          {
            "pagePath": "pages/home/index",
            "text": "首页",
            "iconPath": "./images/icon/home.png",
            "selectedIconPath": "./images/icon/home_selected.png"
          },
          {
            "pagePath": "pages/doc/index",
            "text": "文档",
            "iconPath": "./images/icon/document.png",
            "selectedIconPath": "./images/icon/document_selected.png"
          },{
            "pagePath": "pages/chat/index",
            "text": "消息",
            "iconPath": "./images/icon/chat.png",
            "selectedIconPath": "./images/icon/chat_selected.png"
          },{
            "pagePath": "pages/profile/index",
            "text": "我的",
            "iconPath": "./images/icon/user.png",
            "selectedIconPath": "./images/icon/user_selected.png"
          }
        ]
      },
      "style": "v2",
      "sitemapLocation": "sitemap.json"
    }
    
  • 页面展示效果

    在这里插入图片描述

  • 1
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 1
    评论
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值