微信小程序如何自定义tabBar

追格官方小助手/ 2022年05月30日/ 小程序/ 浏览 1941

自定义 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": {}
}


参考文档:

https://developers.weixin.qq.com/miniprogram/dev/framework/ability/custom-tabbar.html

发表评论

暂无评论,抢个沙发...

客服 工单