根据官方文档自定义小程序taber中,官方演示代码中的aap.json配置项如下:
{
"pages": [
"index/index",
"index/index2"
],
"tabBar": {
"custom": true,
"color": "#7A7E83",
"selectedColor": "#3cc51f",
"borderStyle": "black",
"backgroundColor": "#ffffff",
"list": [
{
"pagePath": "index/index",
"iconPath": "image/icon_component.png",
"selectedIconPath": "image/icon_component_HL.png",
"text": "组件"
},
{
"pagePath": "index/index2",
"iconPath": "image/icon_API.png",
"selectedIconPath": "image/icon_API_HL.png",
"text": "接口"
}
]
},
"window": {
"backgroundTextStyle": "light",
"navigationBarBackgroundColor": "#fff",
"navigationBarTitleText": "WeChat",
"navigationBarTextStyle": "black"
},
"sitemapLocation": "sitemap.json"
}
此段配置运行前提是创建custom-tab-bar 文件夹,并配置相应的taber配置。但是这段配置在使用时会造成首次切换tab时出现短暂消失问题。经多方资料查找,发现疑似官方对taber功能优化时出现的bug。解决问题只需要将配置中的
"custom": true,
删除即可。
"custom": true的目的似乎是为了开启组件taber,也就是使用创建的custom-tab-bar自定义taber。删除此段以后在custom-tab-bar中自定义的样式不可使用,但首次切换页面时不会出现闪烁问题。