tabBar组件

2020-09-20  本文已影响0人  Su9527

一. 全局配置

二. tabBar相关属性

1. list
  • pagePath: 即页面的路径,需要在pages中先定义。
  • text: tab上按钮文字。
  • iconPath: 图片路径,icon 大小限制为 40kb,建议尺寸为 81px * 81px,不支持网络图片。
    当 position 为 top 时,不显示 icon。
  • selectedIconPath: 选中时的图片路径,icon 大小限制为 40kb,建议尺寸为 81px * 81px,不支持网络图片。当 position 为 top 时,不显示 icon。
    "list": [{
      "pagePath": "pages/index/index",
      "text": "主页",
      "iconPath": "resource/tabBar/home.png",
      "selectedIconPath": "resource/tabBar/home-1.png"
    },
    {
      "pagePath": "pages/1-Icon/test",
      "text": "菜单",
      "iconPath": "resource/tabBar/menu.png",
      "selectedIconPath": "resource/tabBar/menu-1.png"
    },
    {
      "pagePath": "pages/index/index",
      "text": "购物车",
      "iconPath": "resource/tabBar/car.png",
      "selectedIconPath": "resource/tabBar/car-1.png"
    },
    {
      "pagePath": "pages/index/index",
      "text": "我的",
      "iconPath": "resource/tabBar/mine.png",
      "selectedIconPath": "resource/tabBar/mine-1.png"
    }]
2. color
    "color": "#dbdbdb",
3. selectedColor
    "selectedColor": "#1296db",
4. backgroundColor
    "backgroundColor": "#ffffff",
5. borderStyle
   "borderStyle": "black",    //  black / white
6. position
   "position": "bottom",    //  bottom / top
7. custom
{
  "tabBar": {
    "custom": true,
    "color": "#000000",
    "selectedColor": "#000000",
    "backgroundColor": "#000000",
    "list": [{
      "pagePath": "page/component/index",
      "text": "组件"
    }, 
    {
      "pagePath": "page/API/index",
      "text": "接口"
    }]
  },
  "usingComponents": {}    // 所有tab页的json里需声明usingComponents项,也可以在app.json中全局开启
}

三. 实现步骤

{
  "pages": [
    "pages/1-Icon/test",
    "pages/index/index",
    "pages/userConsole/userConsole",
    "pages/storageConsole/storageConsole",
    "pages/databaseGuide/databaseGuide",
    "pages/addFunction/addFunction",
    "pages/deployFunctions/deployFunctions",
    "pages/chooseLib/chooseLib",
    "pages/openapi/openapi",
    "pages/openapi/serverapi/serverapi",
    "pages/openapi/callback/callback",
    "pages/openapi/cloudid/cloudid",
    "pages/im/im",
    "pages/im/room/room"
  ],
  "tabBar": {
    "color": "#dbdbdb",
    "selectedColor": "#1296db",
    "backgroundColor": "#ffffff",
    "borderStyle": "black",
    "position": "bottom",
    "list": [{
      "pagePath": "pages/index/index",
      "text": "主页",
      "iconPath": "resource/tabBar/home.png",
      "selectedIconPath": "resource/tabBar/home-1.png"
    },
    {
      "pagePath": "pages/1-Icon/test",
      "text": "菜单",
      "iconPath": "resource/tabBar/menu.png",
      "selectedIconPath": "resource/tabBar/menu-1.png"
    },
    {
      "pagePath": "pages/index/index",
      "text": "购物车",
      "iconPath": "resource/tabBar/car.png",
      "selectedIconPath": "resource/tabBar/car-1.png"
    },
    {
      "pagePath": "pages/index/index",
      "text": "我的",
      "iconPath": "resource/tabBar/mine.png",
      "selectedIconPath": "resource/tabBar/mine-1.png"
    }]
  },
  "window": {
    "backgroundColor": "#F6F6F6",
    "backgroundTextStyle": "light",
    "navigationBarBackgroundColor": "#F6F6F6",
    "navigationBarTitleText": "云开发 QuickStart",
    "navigationBarTextStyle": "black"
  },
  "sitemapLocation": "sitemap.json",
  "style": "v2"
}

四. 效果

effect.png
上一篇 下一篇

猜你喜欢

热点阅读