美文网首页
微信小程序tabBar事件

微信小程序tabBar事件

作者: 荒剑离 | 来源:发表于2020-01-25 23:03 被阅读0次
  • wx.showTabBarRedDot(Object object)
    显示 tabBar 某一项的右上角的红点。
    Object object的属性有index、success、fail和complete,其中index是指tabBar的哪一项,而后三者均为回调函数。

  • wx.showTabBar(Object object)
    显示 tabBar。
    Object object的属性有animation、success、fail和complete,其中animation表示是否需要动画效果,是boolean类型。

  • wx.setTabBarStyle(Object object)
    动态设置 tabBar 的整体样式。
    Object object的属性除了success、fail和complete之外,还有如下样式属性(均为string):

    • color: tab 上的文字默认颜色,HexColor;
    • selectedColor: tab 上的文字选中时的颜色,HexColor;
    • backgroundColor: tab 的背景色,HexColor;
    • borderStyle: tabBar上边框的颜色, 仅支持 black/white。
wx.setTabBarStyle({
  color: '#FF0000',
  selectedColor: '#00FF00',
  backgroundColor: '#0000FF',
  borderStyle: 'white'
})
  • wx.setTabBarItem(Object object)
    动态设置 tabBar 某一项的内容,2.7.0 起图片支持临时文件和网络文件。
    Object object的属性除了有index、success、fail和complete之外,还有如下文本与路径属性(均为string):
    • text: tab 上的按钮文字;
    • iconPath: 图片路径,icon 大小限制为 40kb,建议尺寸为 81px * 81px,当 postion 为 top 时,此参数无效;
    • selectedIconPath: 选中时的图片路径,icon 大小限制为 40kb,建议尺寸为 81px * 81px ,当 postion 为 top 时,此参数无效。
wx.setTabBarItem({
  index: 0,
  text: 'text',
  iconPath: '/path/to/iconPath',
  selectedIconPath: '/path/to/selectedIconPath'
})

相关文章

网友评论

      本文标题:微信小程序tabBar事件

      本文链接:https://www.haomeiwen.com/subject/tjyszctx.html