uniapp中的tabber设置

1,pages.json:
pages.json 文件用来对 uni-app 进行全局配置,决定页面文件的路径、窗口表现、设置多 tab 等。

2,pages.json配置项列表:

  • globalStyle Object 否 设置默认页面的窗口表现。
  • pages Object Array 是 设置页面路径及窗口表现。
  • tabBar Object 否 设置底部 tab 的表现。
  • condition Object 否 启动模式配置。

3,tabBar:
一个多tabbar的应用,可以通过tabBar 配置项指定 tab 栏的表现,以及 tab 切换时显示的对应页。

提示:
① 当设置 position 为 top 时,将不会显示 icon。
② tabBar 中的 list 是一个数组,只能配置最少2个、最多5个 tab,tab 按数组的顺序排序。

tabber属性说明:

① color HexColor 是 tab 上的文字默认颜色。
② selectedColor HexColor 是 tab 上的文字选中时的颜色。
③ backgroundColor HexColor 是 tab 的背景色。
④ borderStyle String 否 black tabbar 上边框的颜色,仅支持 black/white。
⑤ list Array 是 tab 的列表,详见 list 属性说明,最少2个、最多5个 tab。
⑥ position String 否 bottom 可选值 bottom、top。

其中 list 接收一个数组,数组中的每个项都是一个对象,其属性值如下:

① pagePath String 是 页面路径,必须在 pages 中先定义。
② text String 是 tab 上按钮文字。
③ iconPath String 否 图片路径,icon 大小限制为40kb,建议尺寸为 81px * 81px,当 postion 为 top 时,此参数无效,不支持网络图片。
④ selectedIconPath String 否 选中时的图片路径,icon 大小限制为40kb,建议尺寸为 81px * 81px ,当 postion 为 top 时,此参数无效。

代码实例:
① 找到pages.json进行配置。(注意图片路径)
uniapp中的tabber设置
② 设置页面, tabbar里面的页面必须存在所以也要设置pages.json里面的pages字段。
路径如图所示:
uniapp中的tabber设置
效果:
uniapp中的tabber设置