# 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
2
3
4
5
6
7
8
9
10
11
12
success
返回对象示例:
{
"errMsg": "setTabBarItem:ok"
}
1
2
3
2
3