微信小程序API tabBar


本文整理自网络,侵删。

wx.showTabBarRedDot(Object object)

基础库 1.9.0 开始支持,低版本需做兼容处理。

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

参数

Object object

属性 类型 默认值 必填 说明
index number tabBar 的哪一项,从左边算起
success function 接口调用成功的回调函数
fail function 接口调用失败的回调函数
complete function 接口调用结束的回调函数(调用成功、失败都会执行)


wx.showTabBar(Object object)

基础库 1.9.0 开始支持,低版本需做兼容处理。

显示 tabBar

参数

Object object

属性 类型 默认值 必填 说明
animation boolean false 是否需要动画效果
success function 接口调用成功的回调函数
fail function 接口调用失败的回调函数
complete function 接口调用结束的回调函数(调用成功、失败都会执行)




wx.setTabBarStyle(Object object)

基础库 1.9.0 开始支持,低版本需做兼容处理。

动态设置 tabBar 的整体样式

参数

Object object

属性 类型 默认值 必填 说明
color string tab 上的文字默认颜色,HexColor
selectedColor string tab 上的文字选中时的颜色,HexColor
backgroundColor string tab 的背景色,HexColor
borderStyle string tabBar上边框的颜色, 仅支持 black/white
success function 接口调用成功的回调函数
fail function 接口调用失败的回调函数
complete function 接口调用结束的回调函数(调用成功、失败都会执行)

示例代码

wx.setTabBarStyle({
  color: '#FF0000',
  selectedColor: '#00FF00',
  backgroundColor: '#0000FF',
  borderStyle: 'white'
})




wx.setTabBarItem(Object object)

基础库 1.9.0 开始支持,低版本需做兼容处理。

动态设置 tabBar 某一项的内容,2.7.0 起图片支持临时文件和网络文件。

参数

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'
})




wx.setTabBarBadge(Object object)

基础库 1.9.0 开始支持,低版本需做兼容处理。

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

参数

Object object

属性 类型 默认值 必填 说明
index number tabBar 的哪一项,从左边算起
text string 显示的文本,超过 4 个字符则显示成 ...
success function 接口调用成功的回调函数
fail function 接口调用失败的回调函数
complete function 接口调用结束的回调函数(调用成功、失败都会执行)

示例代码

wx.setTabBarBadge({
  index: 0,
  text: '1'
})




wx.removeTabBarBadge(Object object)

基础库 1.9.0 开始支持,低版本需做兼容处理。

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

参数

Object object

属性 类型 默认值 必填 说明
index number tabBar 的哪一项,从左边算起
success function 接口调用成功的回调函数
fail function 接口调用失败的回调函数
complete function 接口调用结束的回调函数(调用成功、失败都会执行)




wx.hideTabBarRedDot(Object object)

基础库 1.9.0 开始支持,低版本需做兼容处理。

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

参数

Object object

属性 类型 默认值 必填 说明
index number tabBar 的哪一项,从左边算起
success function 接口调用成功的回调函数
fail function 接口调用失败的回调函数
complete function 接口调用结束的回调函数(调用成功、失败都会执行)




wx.hideTabBar(Object object)

基础库 1.9.0 开始支持,低版本需做兼容处理。

隐藏 tabBar

参数

Object object

属性类型默认值必填说明
animationbooleanfalse是否需要动画效果
successfunction接口调用成功的回调函数
failfunction接口调用失败的回调函数
completefunction接口调用结束的回调函数(调用成功、失败都会执行)



标签:微信小程序

相关阅读 >>

微信小程序滑块视图容器 滑块视图容器

微信小程序 工具库类lottie

微信小程序api 视频-videocontext

微信小程序 weui顶部错误提示组件

微信小程序api 动画

微信小程序api 设备方向

微信小程序云开发api 获取记录数据

微信小程序api 文件-删除本地缓存文件

微信小程序api nfc-nfca标签

微信小程序api 文件-保存文件系统的文件到用户磁盘

更多相关阅读请进入《微信小程序》频道 >>




打赏

取消

感谢您的支持,我会继续努力的!

扫码支持
扫码打赏,您说多少就多少

打开支付宝扫一扫,即可进行扫码打赏哦

分享从这里开始,精彩与您同在

评论

管理员已关闭评论功能...