目录

Tab Bar

has.showTabBar

has.showTabBar(Object object)

Displays the tab bar.

Since: 1.0.0

Parameters

The input parameter is an object containing the following fields.

Parameter Type Mandatory Description
success function No Callback triggered when the API call is successful.
fail function No Callback triggered when the API call fails.
complete function No Callback triggered when the API call is complete, regardless of success or failure.

Error code information

Error Code Error Message
30000501

showTabBar error. Possible causes: custom tabBar compId is invalid.

For details, see Webview Error Codes.

Example:

has.showTabBar({
  success: () => {
    console.info('showTabBar success');
  },
  fail: (err) => {
    console.error('showTabBar fail', err);
  },
  complete: (res) => {
    console.info('showTabBar complete', res);
  }
});

has.setTabBarBadge

has.setTabBarBadge(Object object)

Adds the text to the upper-right corner of an item in the tab bar.

Since: 1.0.0

Parameters

The input parameter is an object containing the following fields.

Parameter Type Mandatory Description
index number Yes Index of an item in the tab bar, starting from 0 on the left.
text string Yes

Text to be displayed. If the text contains more than four characters, the text is displayed as ···.

NOTE

1. A Chinese character or an English character occupies one character.

2. If an empty string "" is passed to the text parameter, the red badge will not be displayed in the upper right corner of the specified item in the tab bar.

success function No Callback triggered when the API call is successful.
fail function No Callback triggered when the API call fails.
complete function No Callback triggered when the API call is complete, regardless of success or failure.

Error code information

Error Code Error Message
102

Parameter error. Possible causes:

1.text is invalid.

2.index is out of range.

30000701 setTabBarBadge error.
30000702 custom tabBar forbidden to call.

Example:

has.setTabBarBadge({
  index: 1,
  text: '123',
  success: () => {
    console.info('setTabBarBadge success');
  },
  fail: (err) => {
    console.error('setTabBarBadge fail', err);
  },
  complete: (res) => {
    console.info('setTabBarBadge complete', res);
  }
});

has.removeTabBarBadge

has.removeTabBarBadge(Object object)

Deletes the text in the upper-right corner of an item in the tab bar.

Since: 1.0.0

Parameters

The input parameter is an object containing the following fields.

Parameter Type Mandatory Description
index number Yes Index of an item in the tab bar, starting from 0 on the left.
success function No Callback triggered when the API call is successful.
fail function No Callback triggered when the API call fails.
complete function No Callback triggered when the API call is complete, regardless of success or failure.

Error code information

Error Code Error Message
102 Parameter error. Possible causes: index is out of range.
30000801 custom tabBar forbidden to call.
30000802 removeTabBarBadge error.

Example:

has.removeTabBarBadge({
  index: 1,
  success: () => {
    console.info('removeTabBarBadge success');
  },
  fail: (err) => {
    console.error('removeTabBarBadge fail', err);
  },
  complete: (res) => {
    console.info('removeTabBarBadge complete', res);
  }
});

has.hideTabBar

has.hideTabBar(Object object)

Hides the tab bar.

Since: 1.0.0

Parameters

The input parameter is an object containing the following fields.

Parameter Type Mandatory Description
success function No Callback triggered when the API call is successful.
fail function No Callback triggered when the API call fails.
complete function No Callback triggered when the API call is complete, regardless of success or failure.

Error code information

Error Code Error Message
30000601

hideTabBar error. Possible causes: custom tabBar compId is invalid.

For details, see Webview Error Codes.

Example:

has.hideTabBar({
  success: () => {
    console.info('hideTabBar success');
  },
  fail: (err) => {
    console.error('hideTabBar fail', err);
  },
  complete: (res) => {
    console.info('hideTabBar complete', res);
  }
});

has.showTabBarRedDot

has.showTabBarRedDot(Object object)

Displays the red dot in the top-right corner of an item in the tab bar.

Since: 1.0.15

Parameters

The input parameter is an object containing the following fields.

Parameter Type Mandatory Description
index number Yes Index of an item in the tab bar, starting from 0 on the left.
success function No Callback triggered when the API call is successful.
fail function No Callback triggered when the API call fails.
complete function No Callback triggered when the API call is complete, regardless of success or failure.

Error code information

Error Code Error Message
102 Parameter error. Possible causes: index is out of range.
30001601 custom tabBar forbidden to call.
30001602 showTabBarRedDot error.

Example:

has.showTabBarRedDot({
  index: 0,
  success: () => {
    console.info('showTabBarRedDot success');
  },
  fail: (err) => {
    console.error('showTabBarRedDot fail', err);
  },
  complete: (res) => {
    console.info('showTabBarRedDot complete', res);
  }
});

has.hideTabBarRedDot

has.hideTabBarRedDot(Object object)

Hides the red dot in the top-right corner of an item in the tab bar.

Since: 1.0.15

Parameters

The input parameter is an object containing the following fields.

Parameter Type Mandatory Description
index number Yes Index of an item in the tab bar, starting from 0 on the left.
success function No Callback triggered when the API call is successful.
fail function No Callback triggered when the API call fails.
complete function No Callback triggered when the API call is complete, regardless of success or failure.

Error code information

Error Code Error Message
102 Parameter error. Possible causes: index is out of range.
30001701 custom tabBar forbidden to call.
30001702 hideTabBarRedDot error.

Example:

has.hideTabBarRedDot({
  index: 0,
  success: () => {
    console.info('hideTabBarRedDot success');
  },
  fail: (err) => {
    console.error('hideTabBarRedDot fail', err);
  },
  complete: (res) => {
    console.info('hideTabBarRedDot complete', res);
  }
});

has.setTabBarStyle

has.setTabBarStyle(Object object)

Dynamically sets the overall style of the tab bar.

Since: 1.0.15

Parameters

The input parameter is an object containing the following fields.

Parameter Type Mandatory Description
color string No Default color of the text on the tab, in hexadecimal color format.
selectedColor string No Color of the text on the tab when selected, in hexadecimal color format.
backgroundColor string No Background color of the tab, in hexadecimal color format.
borderStyle string No Color of the top border of the tabBar component. The value can only be black or white.
success function No Callback triggered when the API call is successful.
fail function No Callback triggered when the API call fails.
complete function No Callback triggered when the API call is complete, regardless of success or failure.

Error code information

Error Code Error Message
102

Parameter error. Possible causes:

1.color is invalid.

2.invalid borderStyle.

30001801 setTabBarStyle error.
30001802 custom tabBar forbidden to call.

Example:

has.setTabBarStyle({
  color: '#FF0000',
  success: () => {
    console.info('setTabBarStyle success');
  },
  fail: (err) => {
    console.error('setTabBarStyle fail', err);
  },
  complete: (res) => {
    console.info('setTabBarStyle complete', res);
  }
});

has.setTabBarItem

has.setTabBarItem(Object object)

Dynamically sets the content of an item in the tab bar.

Since: 1.0.15

Parameters

The input parameter is an object containing the following fields.

Parameter Type Mandatory Description
index number Yes Index of an item in the tab bar, starting from 0 on the left.
text string No Button text on the tab.
iconPath string No Icon path. The maximum size of an icon is 40 KB. The recommended size is 81 px × 81 px. Online images are not supported.
selectedIconPath string No Selected icon path. The maximum size of an icon is 40 KB. The recommended size is 81 px × 81 px. Online images are not supported.
success function No Callback triggered when the API call is successful.
fail function No Callback triggered when the API call fails.
complete function No Callback triggered when the API call is complete, regardless of success or failure.

Error code information

Error Code Error Message
102

Parameter error. Possible causes:

1.index is out of range.

2.network icons are not currently supported.

3.iconPath is not exist.

30001901 setNavigationBarColor error.
30001902 custom tabBar forbidden to call.

Example:

has.setTabBarItem({
  index: 1,
  text: 'text',
  success: () => {
    console.info('setTabBarItem success');
  },
  fail: (err) => {
    console.error('setTabBarItem fail', err);
  },
  complete: (res) => {
    console.info('setTabBarItem complete', res);
  }
});