小程序开放平台

文档中心
基础
路由
跳转
转发
界面
交互
TabBar
hideTabBar
setTabBarItem
setTabBarStyle
showTabBar
导航栏
下拉刷新
动画
菜单
字体
网络
支付
数据缓存
媒体
位置
开放接口
设备
XHSML
性能
第三方平台
文件
数据分析
画布

xhs.setTabBarItem

开发
>
JS API
>
界面
>
TabBar
>
setTabBarItem
>
更新时间:2024-11-28 20:08:39

以Promise风格调用: 支持

动态设置 tabBar 某一项的内容

参数

Object object

属性
类型
默认值
必填
说明
indexnumbertabBar 的哪一项,从左边算起
textstringtab 上的按钮文字
iconPathstring图片路径,icon 大小限制为 40kb,建议尺寸为 81px * 81px,当 position 为 top 时,此参数无效
selectedIconPathstring选中时的图片路径,icon 大小限制为 40kb,建议尺寸为 81px * 81px ,当 position 为 top 时,此参数无效
successfunction接口调用成功的回调函数
failfunction接口调用失败的回调函数
completefunction接口调用结束的回调函数(调用成功、失败都会执行)

object.success 回调函数

属性
类型
说明
errMsgstring

实例代码

xhs.setTabBarItem({
  index: 0,
  text: 'text',
  iconPath: '/path/to/iconPath',
  selectedIconPath: '/path/to/selectedIconPath'
})