tencent cloud

TabBar

PDF
聚焦模式
字号
最后更新时间: 2024-07-12 19:35:33

showTabBar

该 API 使用方法为 wx.showTabBar(Object object)
功能说明:显示 tabBar。
参数及说明:Object object。
属性
类型
默认值
必填
说明
animation
boolean
false
是否需要动画效果
success
function
-
接口调用成功的回调函数
fail
function
-
接口调用失败的回调函数
complete
function
-
接口调用结束的回调函数(调用成功、失败都会执行)

hideTabBar

该 API 使用方法为 wx.hideTabBar(Object object)
功能说明:隐藏 tabBar。
参数及说明:Object object。
属性
类型
默认值
必填
说明
animation
boolean
false
是否需要动画效果
success
function
-
接口调用成功的回调函数
fail
function
-
接口调用失败的回调函数
complete
function
-
接口调用结束的回调函数(调用成功、失败都会执行)

setTabBarStyle

该 API 使用方法为 wx.setTabBarStyle(Object object)
功能说明:动态设置 tabBar 的整体样式。
参数及说明:Object object。
属性
类型
默认值
必填
说明
color
string
-
tab 上的文字默认颜色,HexColor
selectedColor
string
-
tab 上的文字选中时的颜色,HexColor
backgroundColor
string
-
tab 的背景颜色,HexColor
borderStyle
string
-
tab 上边框的颜色,仅支持 black/white
success
function
-
接口调用成功的回调函数
fail
function
-
接口调用失败的回调函数
complete
function
-
接口调用结束的回调函数(调用成功、失败都会执行)

setTabBarItem

该 API 使用方法为 wx.setTabBarItem(Object object)
功能说明:动态设置 tabBar 某一项的内容。
参数及说明:Object object。
属性
类型
默认值
必填
说明
index
number
-
tabBar 的哪一项,从左边算起
text
string
-
tab 上的按钮文字
iconPath
string
-
图片路径,icon 大小限制为 40kb,建议尺寸为 81px * 81px,当 postion 为 top 时,此参数无效
selectedIconPath
string
-
选中时的图片路径,icon 大小限制为 40kb,建议尺寸为 81px * 81px ,当 postion 为 top 时,此参数无效
success
function
-
接口调用成功的回调函数
fail
function
-
接口调用失败的回调函数
complete
function
-
接口调用结束的回调函数(调用成功、失败都会执行)
示例代码:
wx.setTabBarItem({
index: 0,
text: 'text',
iconPath: '/path/to/iconPath',
selectedIconPath: '/path/to/selectedIconPath'
})

showTabBarRedDot

该 API 使用方法为 wx.showTabBarRedDot(Object object)
功能说明:显示 tabBar 某一项的右上角的红点。
参数及说明:Object object。
属性
类型
默认值
必填
说明
index
number
-
tabBar 的哪一项,从左边算起
success
function
-
接口调用成功的回调函数
fail
function
-
接口调用失败的回调函数
complete
function
-
接口调用结束的回调函数(调用成功、失败都会执行)

hideTabBarRedDot

该 API 使用方法为 wx.hideTabBarRedDot(Object object)
功能说明:隐藏 tabBar 某一项的右上角的红点。
参数及说明:Object object。
属性
类型
默认值
必填
说明
index
number
-
tabBar 的哪一项,从左边算起
success
function
-
接口调用成功的回调函数
fail
function
-
接口调用失败的回调函数
complete
function
-
接口调用结束的回调函数(调用成功、失败都会执行)

setTabBarBadge

该 API 使用方法为 wx.setTabBarBadge(Object object)
功能说明:为 tabBar 某一项的右上角添加文本。
参数及说明:Object object。
属性
类型
默认值
必填
说明
index
number
-
tabBar 的哪一项,从左边算起
text
string
-
显示的文本,超过 4 个字符则显示成 ...
success
function
-
接口调用成功的回调函数
fail
function
-
接口调用失败的回调函数
complete
function
-
接口调用结束的回调函数(调用成功、失败都会执行)
示例代码:
wx.setTabBarBadge({
index: 0,
text: '1'
})

removeTabBarBadge

该 API 使用方法为 wx.removeTabBarBadge(Object object)
功能说明:移除 tabBar 某一项右上角的文本。
参数及说明:Object object。
属性
类型
默认值
必填
说明
index
number
-
tabBar 的哪一项,从左边算起
success
function
-
接口调用成功的回调函数
fail
function
-
接口调用失败的回调函数
complete
function
-
接口调用结束的回调函数(调用成功、失败都会执行)


帮助和支持

本页内容是否解决了您的问题?

填写满意度调查问卷,共创更好文档体验。

文档反馈