Coding With Fun
Home Docker Django Node.js Articles Python pip guide FAQ Policy

WeChat small program API tabBar


May 19, 2021 WeChat Mini Program Development Document


Table of contents


wx.showTabBarRedDot(Object object)

Base library 1.9.0 starts to support, and low versions need to be compatible.

Displays the red dot in the upper right corner of an item of tabBar

Parameters

Object object

Property Type The default Required Description
index number Is TabBar's one, from the left
success function Whether The interface calls a successful callback function
fail function Whether The interface calls the failed callback function
complete function no The callback function ended in the interface call (the call is successful, failed)


wx.showTabBar(Object object)

The base library 1.9.0 began support, low version needs to be done Compatibility

Show tabbar

parameter

Object object

Attributes type Defaults Required illustrate
animation boolean false no Do you need an animation effect?
success function no Interface call successful callback function
fail function no Interface call failed callback function
complete function no The callback function ended in the interface call (the call is successful, failed)




wx.setTabBarStyle(Object object)

The base library 1.9.0 began support, low version needs to be done Compatibility

Dynamic setting TabBar's overall style

parameter

Object object

Attributes type Defaults Required illustrate
color string no Word default color on Tab, HEXCOLOR
selectedColor string no Colors of the text on tab, HEXCOLOR
backgroundColor string Whether Tab background color, HexColor
borderStyle string Whether The color of the border on tabBar, black/white only
success function Whether The interface calls a successful callback function
fail function Whether The interface calls the failed callback function
complete function Whether Callback function at end of interface call (call succeeds, fails are executed)

The sample code

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




wx.setTabBarItem(Object object)

Base library 1.9.0 starts to support, and low versions need to be compatible.

Dynamically set tabBar content for an item, with 2.7.0 images supporting temporary and network files.

Parameters

Object object

Property Type The default Required Description
index number Is TabBar's one, from the left
text string Whether The button text on tab
iconPath string Whether Picture path, icon size limit is 40kb, recommended size is 81px x 81px, this parameter is not valid when postion is top
selectedIconPath string Whether When the picture path is selected, the icon size is limited to 40kb, the recommended size is 81px x 81px, and this parameter is not valid when postion is top
success function Whether The interface calls a successful callback function
fail function Whether The interface calls the failed callback function
complete function Whether Callback function at end of interface call (call succeeds, fails are executed)

The sample code

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




wx.setTabBarBadge(Object object)

Base library 1.9.0 starts to support, and low versions need to be compatible.

Add text to the upper right corner of an item for tabBar

Parameters

Object object

Property Type The default Required Description
index number Is TabBar's one, from the left
text string Is The text displayed, more than 4 characters, is displayed as ...
success function Whether The interface calls a successful callback function
fail function Whether The interface calls the failed callback function
complete function Whether Callback function at end of interface call (call succeeds, fails are executed)

The sample code

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




wx.removeTabBarBadge(Object object)

Base library 1.9.0 starts to support, and low versions need to be compatible.

Remove the text in the upper right corner of an item in tabBar

Parameters

Object object

Property Type The default Required Description
index number Is TabBar's one, from the left
success function Whether The interface calls a successful callback function
fail function Whether The interface calls the failed callback function
complete function Whether Callback function at end of interface call (call succeeds, fails are executed)




wx.hideTabBarRedDot(Object object)

Base library 1.9.0 starts to support, and low versions need to be compatible.

Hides the red dot in the upper right corner of an item in tabBar

Parameters

Object object

Property Type The default Required Description
index number Is TabBar's one, from the left
success function Whether The interface calls a successful callback function
fail function Whether The interface calls the failed callback function
complete function Whether Callback function at end of interface call (call succeeds, fails are executed)




wx.hideTabBar(Object object)

Base library 1.9.0 starts to support, and low versions need to be compatible.

Hide tabBar

Parameters

Object object

Property Type The default Required Description
animation boolean false Whether Whether an animation effect is required
success function Whether The interface calls a successful callback function
fail function Whether The interface calls the failed callback function
complete function Whether Callback function at end of interface call (call succeeds, fails are executed)