# uni.setTabBarBadge(options)

为 tabBar 某一项的右上角添加文本

# 参数

名称 类型 必填 默认值 描述
options SetTabBarBadgeOptions - -
名称 类型 必备 默认值 描述
index number - tabBar的哪一项,从左边算起,索引从0开始
text string - 显示的文本,不超过 3 个半角字符
success (result: AsyncApiSuccessResult) => void - 接口调用成功的回调函数
fail (result: SetTabBarFail) => void - 接口调用失败的回调函数
complete (result: AsyncApiResult) => void - 接口调用结束的回调函数(调用成功、失败都会执行)
# SetTabBarFail 的属性值
名称 类型 必备 默认值 描述
errCode 100 | 200 - 错误码
- 100: TabBar 不存在
- 200: 参数错误
errSubject string - 统一错误主题(模块)名称
data any | null - 错误信息中包含的数据
cause Error | null - 源错误信息,可以包含多个错误,详见SourceError
errMsg string - -
# AsyncApiResult 的属性值
名称 类型 必备 默认值 描述
errMsg string - -

# 返回值

类型 必备
Promise | null

# setTabBarBadge 兼容性

Android iOS web
3.91 4.11 4.0

# 参见

相关 Bug

# uni.removeTabBarBadge(options)

移除 tabBar 某一项右上角的文本

# 参数

名称 类型 必填 默认值 描述
options RemoveTabBarBadgeOptions - -
名称 类型 必备 默认值 描述
index number - tabBar的哪一项,从左边算起,索引从0开始
success (result: AsyncApiSuccessResult) => void - 接口调用成功的回调函数
fail (result: SetTabBarFail) => void - 接口调用失败的回调函数
complete (result: AsyncApiResult) => void - 接口调用结束的回调函数(调用成功、失败都会执行)
# SetTabBarFail 的属性值
名称 类型 必备 默认值 描述
errCode 100 | 200 - 错误码
- 100: TabBar 不存在
- 200: 参数错误
errSubject string - 统一错误主题(模块)名称
data any | null - 错误信息中包含的数据
cause Error | null - 源错误信息,可以包含多个错误,详见SourceError
errMsg string - -
# AsyncApiResult 的属性值
名称 类型 必备 默认值 描述
errMsg string - -

# 返回值

类型 必备
Promise | null

# removeTabBarBadge 兼容性

Android iOS web
3.91 4.11 4.0

# 参见

相关 Bug

# uni.setTabBarItem(options)

动态设置 tabBar 某一项的内容

# 参数

名称 类型 必填 默认值 描述
options SetTabBarItemOptions - -
名称 类型 必备 默认值 描述
index number - tabBar 的哪一项,从左边算起,索引从0开始
text string - tab 上按钮文字
iconPath string - 图片路径
selectedIconPath string - 选中时的图片路径
pagePath string - 页面绝对路径
iconfont SetTabBarItemIconFontOptions - 字体图标,优先级高于 iconPath
名称 类型 必备 默认值 描述
text string - 字库 Unicode 码
selectedText string - 选中后字库 Unicode 码
fontSize string - 字体图标字号(px)
color string - 字体图标颜色
selectedColor string - 字体图标选中颜色
visible boolean - tab 是否显示
success (result: AsyncApiSuccessResult) => void - 接口调用成功的回调函数
fail (result: SetTabBarFail) => void - 接口调用失败的回调函数
complete (result: AsyncApiResult) => void - 接口调用结束的回调函数(调用成功、失败都会执行)
# SetTabBarFail 的属性值
名称 类型 必备 默认值 描述
errCode 100 | 200 - 错误码
- 100: TabBar 不存在
- 200: 参数错误
errSubject string - 统一错误主题(模块)名称
data any | null - 错误信息中包含的数据
cause Error | null - 源错误信息,可以包含多个错误,详见SourceError
errMsg string - -
# AsyncApiResult 的属性值
名称 类型 必备 默认值 描述
errMsg string - -

# 返回值

类型 必备
Promise | null

# setTabBarItem 兼容性

Android iOS web
3.91 4.11 4.0

# 参见

相关 Bug

# uni.setTabBarStyle(options)

动态设置 tabBar 的整体样式

# 参数

名称 类型 必填 默认值 描述
options SetTabBarStyleOptions - -
名称 类型 必备 默认值 描述
color string (string.ColorString) - tab 上的文字默认颜色
selectedColor string (string.ColorString) - tab 上的文字选中时的颜色
backgroundColor string (string.ColorString) - tab 的背景色
backgroundImage string - 图片背景
backgroundRepeat "repeat" | "repeat-x" | "repeat-y" | "no-repeat" - 背景图平铺方式
- repeat: 背景图片在垂直方向和水平方向平铺
- repeat-x: 背景图片在水平方向平铺,垂直方向拉伸
- repeat-y: 背景图片在垂直方向平铺,水平方向拉伸
- no-repeat: 背景图片在垂直方向和水平方向都拉伸
borderStyle string - tabbar上边框的颜色
success (result: AsyncApiSuccessResult) => void - 接口调用成功的回调函数
fail (result: SetTabBarFail) => void - 接口调用失败的回调函数
complete (result: AsyncApiResult) => void - 接口调用结束的回调函数(调用成功、失败都会执行)
# SetTabBarFail 的属性值
名称 类型 必备 默认值 描述
errCode 100 | 200 - 错误码
- 100: TabBar 不存在
- 200: 参数错误
errSubject string - 统一错误主题(模块)名称
data any | null - 错误信息中包含的数据
cause Error | null - 源错误信息,可以包含多个错误,详见SourceError
errMsg string - -
# AsyncApiResult 的属性值
名称 类型 必备 默认值 描述
errMsg string - -

# 返回值

类型 必备
Promise | null

# setTabBarStyle 兼容性

Android iOS web
3.91 4.11 4.0

# 参见

相关 Bug

# uni.hideTabBar(options?)

隐藏 tabBar

# 参数

名称 类型 必填 默认值 描述
options HideTabBarOptions | null -
名称 类型 必备 默认值 描述
animation boolean - 是否需要动画效果
success (result: AsyncApiSuccessResult) => void - 接口调用成功的回调函数
fail (result: SetTabBarFail) => void - 接口调用失败的回调函数
complete (result: AsyncApiResult) => void - 接口调用结束的回调函数(调用成功、失败都会执行)
# SetTabBarFail 的属性值
名称 类型 必备 默认值 描述
errCode 100 | 200 - 错误码
- 100: TabBar 不存在
- 200: 参数错误
errSubject string - 统一错误主题(模块)名称
data any | null - 错误信息中包含的数据
cause Error | null - 源错误信息,可以包含多个错误,详见SourceError
errMsg string - -
# AsyncApiResult 的属性值
名称 类型 必备 默认值 描述
errMsg string - -

# 返回值

类型 必备
Promise | null

# hideTabBar 兼容性

Android iOS web
3.91 4.11 4.0

# 参见

相关 Bug

# uni.showTabBar(options?)

显示 tabBar

# 参数

名称 类型 必填 默认值 描述
options ShowTabBarOptions | null -
名称 类型 必备 默认值 描述
animation boolean - 是否需要动画效果
success (result: AsyncApiSuccessResult) => void - 接口调用成功的回调函数
fail (result: SetTabBarFail) => void - 接口调用失败的回调函数
complete (result: AsyncApiResult) => void - 接口调用结束的回调函数(调用成功、失败都会执行)
# SetTabBarFail 的属性值
名称 类型 必备 默认值 描述
errCode 100 | 200 - 错误码
- 100: TabBar 不存在
- 200: 参数错误
errSubject string - 统一错误主题(模块)名称
data any | null - 错误信息中包含的数据
cause Error | null - 源错误信息,可以包含多个错误,详见SourceError
errMsg string - -
# AsyncApiResult 的属性值
名称 类型 必备 默认值 描述
errMsg string - -

# 返回值

类型 必备
Promise | null

# showTabBar 兼容性

Android iOS web
3.91 4.11 4.0

# 参见

相关 Bug

# uni.showTabBarRedDot(options)

显示 tabBar 某一项的右上角的红点

# 参数

名称 类型 必填 默认值 描述
options ShowTabBarRedDotOptions - -
名称 类型 必备 默认值 描述
index number - tabBar的哪一项,从左边算起,索引从0开始
success (result: AsyncApiSuccessResult) => void - 接口调用成功的回调函数
fail (result: SetTabBarFail) => void - 接口调用失败的回调函数
complete (result: AsyncApiResult) => void - 接口调用结束的回调函数(调用成功、失败都会执行)
# SetTabBarFail 的属性值
名称 类型 必备 默认值 描述
errCode 100 | 200 - 错误码
- 100: TabBar 不存在
- 200: 参数错误
errSubject string - 统一错误主题(模块)名称
data any | null - 错误信息中包含的数据
cause Error | null - 源错误信息,可以包含多个错误,详见SourceError
errMsg string - -
# AsyncApiResult 的属性值
名称 类型 必备 默认值 描述
errMsg string - -

# 返回值

类型 必备
Promise | null

# showTabBarRedDot 兼容性

Android iOS web
3.91 4.11 4.0

# 参见

相关 Bug

# uni.hideTabBarRedDot(options)

隐藏 tabBar 某一项的右上角的红点

# 参数

名称 类型 必填 默认值 描述
options HideTabBarRedDotOptions - -
名称 类型 必备 默认值 描述
index number - tabBar的哪一项,从左边算起,索引从0开始
success (result: AsyncApiSuccessResult) => void - 接口调用成功的回调函数
fail (result: SetTabBarFail) => void - 接口调用失败的回调函数
complete (result: AsyncApiResult) => void - 接口调用结束的回调函数(调用成功、失败都会执行)
# SetTabBarFail 的属性值
名称 类型 必备 默认值 描述
errCode 100 | 200 - 错误码
- 100: TabBar 不存在
- 200: 参数错误
errSubject string - 统一错误主题(模块)名称
data any | null - 错误信息中包含的数据
cause Error | null - 源错误信息,可以包含多个错误,详见SourceError
errMsg string - -
# AsyncApiResult 的属性值
名称 类型 必备 默认值 描述
errMsg string - -

# 返回值

类型 必备
Promise | null

# hideTabBarRedDot 兼容性

Android iOS web
3.91 4.11 4.0

# 参见

相关 Bug

# 通用类型

# GeneralCallbackResult

名称 类型 必备 默认值 描述
errMsg string - 错误信息