Taro.setTabBarItem(option)
Dynamically sets the content of a tabBarn item. For image content, temporary files and network files are supported as of 2.7.0
.
Type
(option: Option) => Promise<CallbackResult>
Parameters
Option
Property | Type | Required | Description |
---|---|---|---|
index | number | Yes | Specifies which item of tabBar, starting from the left |
text | string | No | The text of a button on tab |
iconPath | string | No | The path to the icon. The icon size is limited to 40 KB. Recommended size is 81 px * 81 px, This parameter does not take effect when postion is top. |
selectedIconPath | string | No | The path to the selected icon. The icon size is limited to 40 KB. Recommended size is 81 px * 81 px, This parameter does not take effect when postion is top. |
complete | (res: CallbackResult) => void | No | The callback function used when the API call completed (always executed whether the call succeeds or fails) |
fail | (res: CallbackResult) => void | No | The callback function for a failed API call |
success | (res: CallbackResult) => void | No | The callback function for a successful API call |
Sample Code
Taro.setTabBarItem({
index: 0,
text: 'text',
iconPath: '/path/to/iconPath',
selectedIconPath: '/path/to/selectedIconPath'
})
API Support
API | WeChat Mini-Program | H5 | React Native |
---|---|---|---|
Taro.setTabBarItem | ✔️ | ✔️ | ✔️ |