tabBar
自定义tabBar
在app.json中的tabBar项需要指定custom字段,同时其他tabBar相关配置也会补充齐全
所有tab页的json里需要声明usingComponents 项,也可以在app.json全局开启
{
"tabBar": {
"custom": true,
"color": "#000000",
"selectedColor": "#000000",
"backgroundColor": "#000000",
"list":[{
"pagePath": "page/component/index",
"text": "组件"
},
{
"pagePath": "page/Api/index",
"text": "接口"
}]
},
"usingComponents": {}
}
在代码根目录下添加入口文件(规定名称)
custom-tab-bar/index.js
custom-tab-bar/index.json
custom-tab-bar/index.wxss
custom-tab-bar/index.wxml
编写tabBar代码,该自定义组件完全接管tabBar的渲染
注:
原先的tabBar配置项如list数组等需要全部保留,但在页面中没有作用
为了兼容低版本可能不能支持自定义tabBar时,有默认的tabBar进行显示