# setTabBarItem

动态设置 tabBar(小程序底部tab栏) 某一项的内容

# 支持说明

应用能力 Android iOS PC 预览效果
小程序 3.0.0 3.0.0 3.5.0
扫码预览
用BoosHi扫码或PC端点击
网页应用 X X X /

# 输入

继承标准对象输入,扩展属性描述:

名称 数据类型 必填 默认值 描述
index number tabBar 的哪一项,从左边算起
最小值0
text string tab 上的按钮文字
示例值:'text'
iconPath string 图片路径,建议尺寸为 96px * 96px,当 postion 为 top 时,此参数无效,不支持网络图片
示例值:'static/image/详情.png'
selectedIconPath string 选中时的图片路径,建议尺寸为 96px * 96px ,当 postion 为 top 时,此参数无效
示例值:'static/image/详情.png'

# 输出

继承标准对象输出,无扩展属性

# 示例代码

bz.setTabBarItem({
    index: 0,
    text: "text",
    iconPath: "./image/icon_API.png",
    selectedIconPath: "./image/icon_API.png",
    success(res) {
      console.log(JSON.stringify(res));
    },
    fail(res) {
      console.log(`setTabBarItem fail: ${JSON.stringify(res)}`);
    }
});
1
2
3
4
5
6
7
8
9
10
11
12

success返回对象示例:

{
    "errMsg": "setTabBarItem:ok"
}
1
2
3
最后更新于 : 12/15/2022, 2:18:25 PM