has.setNavigationBarTitle
has.setNavigationBarTitle(Object object)
Dynamically sets the title text of the current page.
Since: 1.0.0
Parameters
The input parameter is an object containing the following fields.
| Parameter | Type | Mandatory | Description |
| title | string | Yes | Title text to set. |
| 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.title is required. 2.check type is invalid. |
| 30001001 | setNavigationBarTitle error. |
Example:
has.setNavigationBarTitle({
title: 'Current page',
success: () => {
console.info('setNavigationBarTitle success');
},
fail: (err) => {
console.error('setNavigationBarTitle fail', err);
},
complete: (res) => {
console.info('setNavigationBarTitle complete', res);
}
}); has.setNavigationBarColor
has.setNavigationBarColor(Object object)
Dynamically sets the color of the navigation bar on the current page.
Since: 1.0.0
Parameters
The input parameter is an object containing the following fields.
| Parameter | Type | Mandatory | Description |
| frontColor | string | Yes | Foreground color, including the colors of buttons, titles, and status bars. For HarmonyOS API 12, the value can be set to #000000 or #FFFFFF only when navigationStyle is set to custom for a window. Otherwise, only #000000 is supported. For HarmonyOS API 13 or later, the value can be set to #000000 or #FFFFFF. |
| backgroundColor | string | Yes | Background color, which must be a hexadecimal value. |
| 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.frontColor is required. 2.backgroundColor is required. 3.check type is invalid. |
| 30000901 | setNavigationBarColor error. |
Example:
has.setNavigationBarColor({
frontColor: '#000000',
backgroundColor: '#ff0000',
success: () => {
console.info('setNavigationBarColor success');
},
fail: (err) => {
console.error('setNavigationBarColor fail', err);
},
complete: (res) => {
console.info('setNavigationBarColor complete', res);
}
});