提交 53700a49 编写于 作者: E ester.zhou

Update docs (22145)

Signed-off-by: Nester.zhou <ester.zhou@huawei.com>
上级 876e3b5f
...@@ -15,12 +15,11 @@ Environment is a singleton object created by the ArkUI framework at application ...@@ -15,12 +15,11 @@ Environment is a singleton object created by the ArkUI framework at application
- Use **Environment.EnvProp** to save the environment variables of the device to AppStorage. - Use **Environment.EnvProp** to save the environment variables of the device to AppStorage.
```ts ```ts
// Save the language code of the device to AppStorage. The default value is en. // Save languageCode to AppStorage. The default value is en.
// Whenever its value changes in the device environment, it will update its value in AppStorage.
Environment.EnvProp('languageCode', 'en'); Environment.EnvProp('languageCode', 'en');
``` ```
- To keep a component variable updated with changes in the device environment, this variable should be decorated with \@StorageProp. - Decorate the variables with \@StorageProp to link them with components.
```ts ```ts
@StorageProp('languageCode') lang : string = 'en'; @StorageProp('languageCode') lang : string = 'en';
...@@ -29,6 +28,7 @@ Environment is a singleton object created by the ArkUI framework at application ...@@ -29,6 +28,7 @@ Environment is a singleton object created by the ArkUI framework at application
The chain of updates is as follows: Environment > AppStorage > Component. The chain of updates is as follows: Environment > AppStorage > Component.
> **NOTE** > **NOTE**
>
> An \@StorageProp decorated variable can be locally modified, but the change will not be updated to AppStorage. This is because the environment variable parameters are read-only to the application. > An \@StorageProp decorated variable can be locally modified, but the change will not be updated to AppStorage. This is because the environment variable parameters are read-only to the application.
...@@ -69,3 +69,29 @@ if (lang.get() === 'en') { ...@@ -69,3 +69,29 @@ if (lang.get() === 'en') {
console.info('Hello!'); console.info('Hello!');
} }
``` ```
## Restrictions
Environment can be called only when the [UIContext](../reference/apis/js-apis-arkui-UIContext.md#uicontext), which can be obtained through [runScopedTask](../reference/apis/js-apis-arkui-UIContext.md#runscopedtask), is specified. If Environment is called otherwise, no device environment data can be obtained.
```ts
// EntryAbility.ts
import UIAbility from '@ohos.app.ability.UIAbility';
import window from '@ohos.window';
export default class EntryAbility extends UIAbility {
onWindowStageCreate(windowStage: window.WindowStage) {
windowStage.loadContent('pages/Index');
let window = windowStage.getMainWindow()
window.then(window => {
let uicontext = window.getUIContext()
uicontext.runScopedTask(() => {
Environment.EnvProp('languageCode', 'en');
})
})
}
}
```
...@@ -139,6 +139,8 @@ animateTo(value: AnimateParam, event: () => void): void ...@@ -139,6 +139,8 @@ animateTo(value: AnimateParam, event: () => void): void
Applies a transition animation for state changes. Applies a transition animation for state changes.
**System capability**: SystemCapability.ArkUI.ArkUI.Full
Since API version 9, this API is supported in ArkTS widgets. Since API version 9, this API is supported in ArkTS widgets.
**Parameters** **Parameters**
...@@ -216,11 +218,14 @@ showAlertDialog(options: AlertDialogParamWithConfirm | AlertDialogParamWithButto ...@@ -216,11 +218,14 @@ showAlertDialog(options: AlertDialogParamWithConfirm | AlertDialogParamWithButto
Shows an alert dialog box. Shows an alert dialog box.
**System capability**: SystemCapability.ArkUI.ArkUI.Full
**Parameters** **Parameters**
| Name | Type | Description| | Name | Type | Mandatory| Description|
| ---- | --------------- | -------- | | ---- | --------------- | -------- | -------- |
| options | [AlertDialogParamWithConfirm](../arkui-ts/ts-methods-alert-dialog-box.md#alertdialogparamwithconfirm) \| [AlertDialogParamWithButtons](../arkui-ts/ts-methods-alert-dialog-box.md#alertdialogparamwithbuttons) | Defines and displays the **\<AlertDialog>** component.| | options | [AlertDialogParamWithConfirm](../arkui-ts/ts-methods-alert-dialog-box.md#alertdialogparamwithconfirm) \| [AlertDialogParamWithButtons](../arkui-ts/ts-methods-alert-dialog-box.md#alertdialogparamwithbuttons) | Yes| Defines and displays the **\<AlertDialog>** component.|
**Example** **Example**
...@@ -252,9 +257,11 @@ showActionSheet(value: ActionSheetOptions): void ...@@ -252,9 +257,11 @@ showActionSheet(value: ActionSheetOptions): void
Defines and shows the action sheet. Defines and shows the action sheet.
**System capability**: SystemCapability.ArkUI.ArkUI.Full
**ActionSheetOptions parameters** **ActionSheetOptions parameters**
| Name | Type | Mandatory | Description | | Name | Type | Mandatory | Description |
| ---------- | -------------------------- | ------- | ----------------------------- | | ---------- | -------------------------- | ------- | ----------------------------- |
| title | [Resource](../arkui-ts/ts-types.md#resource) \| string | Yes | Title of the dialog box.| | title | [Resource](../arkui-ts/ts-types.md#resource) \| string | Yes | Title of the dialog box.|
| message | [Resource](../arkui-ts/ts-types.md#resource) \| string | Yes | Content of the dialog box. | | message | [Resource](../arkui-ts/ts-types.md#resource) \| string | Yes | Content of the dialog box. |
...@@ -267,7 +274,7 @@ Defines and shows the action sheet. ...@@ -267,7 +274,7 @@ Defines and shows the action sheet.
**SheetInfo parameters** **SheetInfo parameters**
| Name| Type | Mandatory| Description | | Name| Type | Mandatory| Description |
| ------ | ------------------------------------------------------------ | ---- | ----------------- | | ------ | ------------------------------------------------------------ | ---- | ----------------- |
| title | [ResourceStr](../arkui-ts/ts-types.md#resourcestr) | Yes | Text of the option. | | title | [ResourceStr](../arkui-ts/ts-types.md#resourcestr) | Yes | Text of the option. |
| icon | [ResourceStr](../arkui-ts/ts-types.md#resourcestr) | No | Sheet icon. By default, no icon is displayed. | | icon | [ResourceStr](../arkui-ts/ts-types.md#resourcestr) | No | Sheet icon. By default, no icon is displayed. |
...@@ -320,22 +327,24 @@ showDatePickerDialog(options: DatePickerDialogOptions): void ...@@ -320,22 +327,24 @@ showDatePickerDialog(options: DatePickerDialogOptions): void
Shows a date picker dialog box. Shows a date picker dialog box.
**System capability**: SystemCapability.ArkUI.ArkUI.Full
**DatePickerDialogOptions parameters** **DatePickerDialogOptions parameters**
| Name| Type| Mandatory| Default Value| Description| | Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- | -------- | | -------- | -------- | -------- | -------- |
| start | Date | No| Date('1970-1-1') | Start date of the picker.| | start | Date | No| Start date of the picker.<br>Default value: **Date('1970-1-1')**|
| end | Date | No| Date('2100-12-31') | End date of the picker.| | end | Date | No| End date of the picker.<br>Default value: **Date('2100-12-31')**|
| selected | Date | No| Current system date| Selected date.| | selected | Date | No| Selected date.<br>Default value: current system date|
| lunar | boolean | No| false | Whether to display the lunar calendar.| | lunar | boolean | No| Whether to display the lunar calendar.<br>Default value: **false**|
| showTime | boolean | No| false | Whether to display the time item.| | showTime | boolean | No| Whether to display the time item.<br>Default value: **false**|
| useMilitaryTime | boolean | No| false | Whether to display time in 24-hour format.| | useMilitaryTime | boolean | No| Whether to display time in 24-hour format.<br>Default value: **false**|
| disappearTextStyle | [PickerTextStyle](../arkui-ts/ts-basic-components-datepicker.md#pickertextstyle10) | No| - | Font color, font size, and font width for the top and bottom items.| | disappearTextStyle | [PickerTextStyle](../arkui-ts/ts-basic-components-datepicker.md#pickertextstyle10) | No| Font color, font size, and font width for the top and bottom items.|
| textStyle | [PickerTextStyle](../arkui-ts/ts-basic-components-datepicker.md#pickertextstyle10) | No| - | Font color, font size, and font width of all items except the top, bottom, and selected items.| | textStyle | [PickerTextStyle](../arkui-ts/ts-basic-components-datepicker.md#pickertextstyle10) | No| Font color, font size, and font width of all items except the top, bottom, and selected items.|
| selectedTextStyle | [PickerTextStyle](../arkui-ts/ts-basic-components-datepicker.md#pickertextstyle10) | No| - | Font color, font size, and font width of the selected item.| | selectedTextStyle | [PickerTextStyle](../arkui-ts/ts-basic-components-datepicker.md#pickertextstyle10) | No| Font color, font size, and font width of the selected item.|
| onAccept | (value: [DatePickerResult](../arkui-ts/ts-basic-components-datepicker.md#datepickerresult)) => void | No| - | Callback invoked when the OK button in the dialog box is clicked.| | onAccept | (value: [DatePickerResult](../arkui-ts/ts-basic-components-datepicker.md#datepickerresult)) => void | No| Callback invoked when the OK button in the dialog box is clicked.|
| onCancel | () => void | No| - | Callback invoked when the Cancel button in the dialog box is clicked.| | onCancel | () => void | No| Callback invoked when the Cancel button in the dialog box is clicked.|
| onChange | (value: [DatePickerResult](../arkui-ts/ts-basic-components-datepicker.md#datepickerresult)) => void | No| - | Callback invoked when the selected item in the picker changes.| | onChange | (value: [DatePickerResult](../arkui-ts/ts-basic-components-datepicker.md#datepickerresult)) => void | No| Callback invoked when the selected item in the picker changes.|
**Example** **Example**
...@@ -365,6 +374,8 @@ showTimePickerDialog(options: TimePickerDialogOptions): void ...@@ -365,6 +374,8 @@ showTimePickerDialog(options: TimePickerDialogOptions): void
Shows a time picker dialog box. Shows a time picker dialog box.
**System capability**: SystemCapability.ArkUI.ArkUI.Full
**TimePickerDialogOptions parameters** **TimePickerDialogOptions parameters**
| Name| Type| Mandatory| Description| | Name| Type| Mandatory| Description|
...@@ -404,9 +415,11 @@ showTextPickerDialog(options: TextPickerDialogOptions): void ...@@ -404,9 +415,11 @@ showTextPickerDialog(options: TextPickerDialogOptions): void
Shows a text picker in the given settings. Shows a text picker in the given settings.
**System capability**: SystemCapability.ArkUI.ArkUI.Full
**TextPickerDialogOptions parameters** **TextPickerDialogOptions parameters**
| Name| Type| Mandatory| Description| | Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- | | -------- | -------- | -------- | -------- |
| range | string[] \| [Resource](../arkui-ts/ts-types.md#resource)\|[TextPickerRangeContent](../arkui-ts/ts-basic-components-textpicker.md#textpickerrangecontent10)[] | Yes| Data selection range of the picker. This parameter cannot be set to an empty array. If set to an empty array, it will not be displayed.| | range | string[] \| [Resource](../arkui-ts/ts-types.md#resource)\|[TextPickerRangeContent](../arkui-ts/ts-basic-components-textpicker.md#textpickerrangecontent10)[] | Yes| Data selection range of the picker. This parameter cannot be set to an empty array. If set to an empty array, it will not be displayed.|
| selected | number | No| Index of the selected item.<br>Default value: **0**| | selected | number | No| Index of the selected item.<br>Default value: **0**|
...@@ -507,7 +520,7 @@ In the following API examples, you must first use [getFont()](#getfont) in **UIC ...@@ -507,7 +520,7 @@ In the following API examples, you must first use [getFont()](#getfont) in **UIC
### registerFont ### registerFont
registerFont(options: FontOptions): void registerFont(options: font.FontOptions): void
Registers a custom font with the font manager. Registers a custom font with the font manager.
...@@ -515,9 +528,9 @@ Registers a custom font with the font manager. ...@@ -515,9 +528,9 @@ Registers a custom font with the font manager.
**Parameters** **Parameters**
| Name | Type | Mandatory | Description | | Name | Type | Mandatory| Description |
| ------- | --------------------------- | ---- | ----------- | | ------- | ----------------------------------------------- | ---- | ---------------------- |
| options | [FontOptions](js-apis-font.md#fontoptions) | Yes | Information about the custom font to register.| | options | [font.FontOptions](js-apis-font.md#fontoptions) | Yes | Information about the custom font to register.|
**Example** **Example**
...@@ -528,13 +541,61 @@ font.registerFont({ ...@@ -528,13 +541,61 @@ font.registerFont({
familySrc: '/font/medium.ttf' familySrc: '/font/medium.ttf'
}); });
``` ```
### getStstemFontList
getSystemFontList(): Array\<string>
Obtains the list of supported fonts.
**System capability**: SystemCapability.ArkUI.ArkUI.Full
**Return value**
| Type | Description |
| -------------- | ------------------ |
| Array\<string> | List of supported fonts.|
**Example**
```ts
let font = uiContext.getFont();
font.getSystemFontList()
```
### getFontByName
getFontByName(fontName: string): font.FontInfo
Obtains information about a system font based on the font name.
**System capability**: SystemCapability.ArkUI.ArkUI.Full
**Parameters**
| Name | Type | Mandatory| Description |
| -------- | ------ | ---- | -------------- |
| fontName | string | Yes | System font name.|
**Return value**
| Type | Description |
| ------------------------------------ | -------------- |
| [FontInfo](js-apis-font.md#fontinfo10) | Information about the system font.|
**Example**
```ts
let font = uiContext.getFont();
font.getFontByName('Sans Italic')
```
## ComponentUtils ## ComponentUtils
In the following API examples, you must first use [getComponentUtils()](#getcomponentutils) in **UIContext** to obtain a **ComponentUtils** instance, and then call the APIs using the obtained instance. In the following API examples, you must first use [getComponentUtils()](#getcomponentutils) in **UIContext** to obtain a **ComponentUtils** instance, and then call the APIs using the obtained instance.
### getRectangleById ### getRectangleById
getRectangleById(key: string): ComponentInfo getRectangleById(id: string): componentUtils.ComponentInfo
Obtains the size, position, translation, scaling, rotation, and affine matrix information of the specified component. Obtains the size, position, translation, scaling, rotation, and affine matrix information of the specified component.
...@@ -544,13 +605,13 @@ Obtains the size, position, translation, scaling, rotation, and affine matrix in ...@@ -544,13 +605,13 @@ Obtains the size, position, translation, scaling, rotation, and affine matrix in
| Name| Type | Mandatory| Description | | Name| Type | Mandatory| Description |
| ------ | ------ | ---- | ---------------- | | ------ | ------ | ---- | ---------------- |
| key | string | Yes | Unique component ID.| | id | string | Yes | Unique component ID.|
**Return value** **Return value**
| Type | Description | | Type | Description |
| ------------- | ------------------------------------------------------------ | | -------------------------------------------------------- | ------------------------------------------------ |
| ComponentInfo | Size, position, translation, scaling, rotation, and affine matrix information of the component. | | [ComponentInfo](js-apis-arkui-componentUtils.md#componentinfo) | Size, position, translation, scaling, rotation, and affine matrix information of the component.|
**Example** **Example**
...@@ -567,7 +628,7 @@ In the following API examples, you must first use [getUIInspector()](#getuiinspe ...@@ -567,7 +628,7 @@ In the following API examples, you must first use [getUIInspector()](#getuiinspe
### createComponentObserver ### createComponentObserver
createComponentObserver(id: string): ComponentObserver createComponentObserver(id: string): inspector.ComponentObserver
Creates an observer for the specified component. Creates an observer for the specified component.
...@@ -581,8 +642,8 @@ Creates an observer for the specified component. ...@@ -581,8 +642,8 @@ Creates an observer for the specified component.
**Return value** **Return value**
| Type | Description | | Type | Description |
| --------------------------------------- | -------------------------------------------------- | | ------------------------------------------------------------ | -------------------------------------------------- |
| [ComponentObserver](js-apis-arkui-inspector.md#componentobserver) | Component observer, which is used to register and unregister listeners for completion of component layout or drawing.| | [ComponentObserver](js-apis-arkui-inspector.md#componentobserver) | Component observer, which is used to register and unregister listeners for completion of component layout or drawing.|
**Example** **Example**
...@@ -598,7 +659,7 @@ In the following API examples, you must first use [getMediaQuery()](#getmediaque ...@@ -598,7 +659,7 @@ In the following API examples, you must first use [getMediaQuery()](#getmediaque
### matchMediaSync ### matchMediaSync
matchMediaSync(condition: string): MediaQueryListener matchMediaSync(condition: string): mediaQuery.MediaQueryListener
Sets the media query criteria and returns the corresponding listening handle. Sets the media query criteria and returns the corresponding listening handle.
...@@ -629,7 +690,7 @@ In the following API examples, you must first use [getRouter()](#getrouter) in * ...@@ -629,7 +690,7 @@ In the following API examples, you must first use [getRouter()](#getrouter) in *
### pushUrl ### pushUrl
pushUrl(options: RouterOptions): Promise&lt;void&gt; pushUrl(options: router.RouterOptions): Promise&lt;void&gt;
Navigates to a specified page in the application. Navigates to a specified page in the application.
...@@ -637,9 +698,9 @@ Navigates to a specified page in the application. ...@@ -637,9 +698,9 @@ Navigates to a specified page in the application.
**Parameters** **Parameters**
| Name | Type | Mandatory | Description | | Name | Type | Mandatory| Description |
| ------- | ------------------------------- | ---- | --------- | | ------- | ------------------------------------------------------- | ---- | ------------------ |
| options | [RouterOptions](js-apis-router.md#routeroptions) | Yes | Page routing parameters.| | options | [router.RouterOptions](js-apis-router.md#routeroptions) | Yes | Page routing parameters.|
**Return value** **Return value**
...@@ -680,7 +741,7 @@ router.pushUrl({ ...@@ -680,7 +741,7 @@ router.pushUrl({
### pushUrl ### pushUrl
pushUrl(options: RouterOptions, callback: AsyncCallback&lt;void&gt;): void pushUrl(options: router.RouterOptions, callback: AsyncCallback&lt;void&gt;): void
Navigates to a specified page in the application. Navigates to a specified page in the application.
...@@ -690,7 +751,7 @@ Navigates to a specified page in the application. ...@@ -690,7 +751,7 @@ Navigates to a specified page in the application.
| Name | Type | Mandatory | Description | | Name | Type | Mandatory | Description |
| ------- | ------------------------------- | ---- | --------- | | ------- | ------------------------------- | ---- | --------- |
| options | [RouterOptions](js-apis-router.md#routeroptions) | Yes | Page routing parameters.| | options | [router.RouterOptions](js-apis-router.md#routeroptions) | Yes | Page routing parameters.|
| callback | AsyncCallback&lt;void&gt; | Yes | Callback used to return the result. | | callback | AsyncCallback&lt;void&gt; | Yes | Callback used to return the result. |
**Error codes** **Error codes**
...@@ -726,7 +787,7 @@ router.pushUrl({ ...@@ -726,7 +787,7 @@ router.pushUrl({
### pushUrl ### pushUrl
pushUrl(options: RouterOptions, mode: RouterMode): Promise&lt;void&gt; pushUrl(options: router.RouterOptions, mode: router.RouterMode): Promise&lt;void&gt;
Navigates to a specified page in the application. Navigates to a specified page in the application.
...@@ -734,10 +795,10 @@ Navigates to a specified page in the application. ...@@ -734,10 +795,10 @@ Navigates to a specified page in the application.
**Parameters** **Parameters**
| Name | Type | Mandatory | Description | | Name | Type | Mandatory| Description |
| ------- | ------------------------------- | ---- | ---------- | | ------- | ------------------------------------------------------- | ---- | -------------------- |
| options | [RouterOptions](js-apis-router.md#routeroptions) | Yes | Page routing parameters. | | options | [router.RouterOptions](js-apis-router.md#routeroptions) | Yes | Page routing parameters. |
| mode | [RouterMode](js-apis-router.md#routermode9) | Yes | Routing mode.| | mode | [router.RouterMode](js-apis-router.md#routermode9) | Yes | Routing mode.|
**Return value** **Return value**
...@@ -778,7 +839,7 @@ router.pushUrl({ ...@@ -778,7 +839,7 @@ router.pushUrl({
### pushUrl ### pushUrl
pushUrl(options: RouterOptions, mode: RouterMode, callback: AsyncCallback&lt;void&gt;): void pushUrl(options: router.RouterOptions, mode: router.RouterMode, callback: AsyncCallback&lt;void&gt;): void
Navigates to a specified page in the application. Navigates to a specified page in the application.
...@@ -788,8 +849,8 @@ Navigates to a specified page in the application. ...@@ -788,8 +849,8 @@ Navigates to a specified page in the application.
| Name | Type | Mandatory | Description | | Name | Type | Mandatory | Description |
| ------- | ------------------------------- | ---- | ---------- | | ------- | ------------------------------- | ---- | ---------- |
| options | [RouterOptions](js-apis-router.md#routeroptions) | Yes | Page routing parameters. | | options | [router.RouterOptions](js-apis-router.md#routeroptions) | Yes | Page routing parameters. |
| mode | [RouterMode](js-apis-router.md#routermode9) | Yes | Routing mode.| | mode | [router.RouterMode](js-apis-router.md#routermode9) | Yes | Routing mode.|
| callback | AsyncCallback&lt;void&gt; | Yes | Callback used to return the result. | | callback | AsyncCallback&lt;void&gt; | Yes | Callback used to return the result. |
**Error codes** **Error codes**
...@@ -825,17 +886,17 @@ router.pushUrl({ ...@@ -825,17 +886,17 @@ router.pushUrl({
### replaceUrl ### replaceUrl
replaceUrl(options: RouterOptions): Promise&lt;void&gt; replaceUrl(options: router.RouterOptions): Promise&lt;void&gt;
Replaces the current page with another one in the application and destroys the current page. Replaces the current page with another one in the application and destroys the current page.
**System capability**: SystemCapability.ArkUI.ArkUI.Lite **System capability**: SystemCapability.ArkUI.ArkUI.Full
**Parameters** **Parameters**
| Name | Type | Mandatory| Description | | Name | Type | Mandatory| Description |
| ------- | ------------------------------- | ---- | ------------------ | | ------- | ------------------------------------------------------- | ---- | ------------------ |
| options | [RouterOptions](js-apis-router.md#routeroptions) | Yes | Description of the new page.| | options | [router.RouterOptions](js-apis-router.md#routeroptions) | Yes | Description of the new page.|
**Return value** **Return value**
...@@ -872,17 +933,17 @@ router.replaceUrl({ ...@@ -872,17 +933,17 @@ router.replaceUrl({
### replaceUrl ### replaceUrl
replaceUrl(options: RouterOptions, callback: AsyncCallback&lt;void&gt;): void replaceUrl(options: router.RouterOptions, callback: AsyncCallback&lt;void&gt;): void
Replaces the current page with another one in the application and destroys the current page. Replaces the current page with another one in the application and destroys the current page.
**System capability**: SystemCapability.ArkUI.ArkUI.Lite **System capability**: SystemCapability.ArkUI.ArkUI.Full
**Parameters** **Parameters**
| Name | Type | Mandatory| Description | | Name | Type | Mandatory| Description |
| ------- | ------------------------------- | ---- | ------------------ | | ------- | ------------------------------- | ---- | ------------------ |
| options | [RouterOptions](js-apis-router.md#routeroptions) | Yes | Description of the new page.| | options | [router.RouterOptions](js-apis-router.md#routeroptions) | Yes | Description of the new page.|
| callback | AsyncCallback&lt;void&gt; | Yes | Callback used to return the result. | | callback | AsyncCallback&lt;void&gt; | Yes | Callback used to return the result. |
**Error codes** **Error codes**
...@@ -914,18 +975,18 @@ router.replaceUrl({ ...@@ -914,18 +975,18 @@ router.replaceUrl({
### replaceUrl ### replaceUrl
replaceUrl(options: RouterOptions, mode: RouterMode): Promise&lt;void&gt; replaceUrl(options: router.RouterOptions, mode: router.RouterMode): Promise&lt;void&gt;
Replaces the current page with another one in the application and destroys the current page. Replaces the current page with another one in the application and destroys the current page.
**System capability**: SystemCapability.ArkUI.ArkUI.Lite **System capability**: SystemCapability.ArkUI.ArkUI.Full
**Parameters** **Parameters**
| Name | Type | Mandatory | Description | | Name | Type | Mandatory| Description |
| ------- | ------------------------------- | ---- | ---------- | | ------- | ------------------------------------------------------- | ---- | -------------------- |
| options | [RouterOptions](js-apis-router.md#routeroptions) | Yes | Description of the new page. | | options | [router.RouterOptions](js-apis-router.md#routeroptions) | Yes | Description of the new page. |
| mode | [RouterMode](js-apis-router.md#routermode9) | Yes | Routing mode.| | mode | [router.RouterMode](js-apis-router.md#routermode9) | Yes | Routing mode.|
**Return value** **Return value**
...@@ -946,34 +1007,32 @@ For details about the error codes, see [Router Error Codes](../errorcodes/errorc ...@@ -946,34 +1007,32 @@ For details about the error codes, see [Router Error Codes](../errorcodes/errorc
```ts ```ts
let router = uiContext.getRouter(); let router = uiContext.getRouter();
router.replaceUrl({ try {
url: 'pages/detail', router.replaceUrl({
params: { url: 'pages/detail',
data1: 'message' params: {
} data1: 'message'
}, router.RouterMode.Standard) }
.then(() => { }, router.RouterMode.Standard)
// success } catch (err) {
}) console.error(`replaceUrl failed, code is ${err.code}, message is ${err.message}`);
.catch(err => { }
console.error(`replaceUrl failed, code is ${err.code}, message is ${err.message}`);
})
``` ```
### replaceUrl ### replaceUrl
replaceUrl(options: RouterOptions, mode: RouterMode, callback: AsyncCallback&lt;void&gt;): void replaceUrl(options: router.RouterOptions, mode: router.RouterMode, callback: AsyncCallback&lt;void&gt;): void
Replaces the current page with another one in the application and destroys the current page. Replaces the current page with another one in the application and destroys the current page.
**System capability**: SystemCapability.ArkUI.ArkUI.Lite **System capability**: SystemCapability.ArkUI.ArkUI.Full
**Parameters** **Parameters**
| Name | Type | Mandatory | Description | | Name | Type | Mandatory | Description |
| ------- | ------------------------------- | ---- | ---------- | | ------- | ------------------------------- | ---- | ---------- |
| options | [RouterOptions](js-apis-router.md#routeroptions) | Yes | Description of the new page. | | options | [router.RouterOptions](js-apis-router.md#routeroptions) | Yes | Description of the new page. |
| mode | [RouterMode](js-apis-router.md#routermode9) | Yes | Routing mode.| | mode | [router.RouterMode](js-apis-router.md#routermode9) | Yes | Routing mode.|
| callback | AsyncCallback&lt;void&gt; | Yes | Callback used to return the result. | | callback | AsyncCallback&lt;void&gt; | Yes | Callback used to return the result. |
**Error codes** **Error codes**
...@@ -1005,7 +1064,7 @@ router.replaceUrl({ ...@@ -1005,7 +1064,7 @@ router.replaceUrl({
### pushNamedRoute ### pushNamedRoute
pushNamedRoute(options: NamedRouterOptions): Promise&lt;void&gt; pushNamedRoute(options: router.NamedRouterOptions): Promise&lt;void&gt;
Navigates to a page using the named route. This API uses a promise to return the result. Navigates to a page using the named route. This API uses a promise to return the result.
...@@ -1013,9 +1072,9 @@ Navigates to a page using the named route. This API uses a promise to return the ...@@ -1013,9 +1072,9 @@ Navigates to a page using the named route. This API uses a promise to return the
**Parameters** **Parameters**
| Name | Type | Mandatory | Description | | Name | Type | Mandatory| Description |
| ------- | ------------------------------- | ---- | --------- | | ------- | ------------------------------------------------------------ | ---- | ------------------ |
| options | [NamedRouterOptions](js-apis-router.md#namedrouteroptions10) | Yes | Page routing parameters.| | options | [router.NamedRouterOptions](js-apis-router.md#namedrouteroptions10) | Yes | Page routing parameters.|
**Return value** **Return value**
...@@ -1056,9 +1115,9 @@ router.pushNamedRoute({ ...@@ -1056,9 +1115,9 @@ router.pushNamedRoute({
### pushNamedRoute ### pushNamedRoute
pushNamedRoute(options: NamedRouterOptions, callback: AsyncCallback&lt;void&gt;): void pushNamedRoute(options: router.NamedRouterOptions, callback: AsyncCallback&lt;void&gt;): void
Navigates to a page using the named route. This API uses an asynchronous callback to return the result. Navigates to a page using the named route. This API uses a promise to return the result.
**System capability**: SystemCapability.ArkUI.ArkUI.Full **System capability**: SystemCapability.ArkUI.ArkUI.Full
...@@ -1066,7 +1125,7 @@ Navigates to a page using the named route. This API uses an asynchronous callbac ...@@ -1066,7 +1125,7 @@ Navigates to a page using the named route. This API uses an asynchronous callbac
| Name | Type | Mandatory | Description | | Name | Type | Mandatory | Description |
| ------- | ------------------------------- | ---- | --------- | | ------- | ------------------------------- | ---- | --------- |
| options | [NamedRouterOptions](js-apis-router.md#namedrouteroptions10) | Yes | Page routing parameters.| | options | [router.NamedRouterOptions](js-apis-router.md#namedrouteroptions10) | Yes | Page routing parameters.|
| callback | AsyncCallback&lt;void&gt; | Yes | Callback used to return the result. | | callback | AsyncCallback&lt;void&gt; | Yes | Callback used to return the result. |
**Error codes** **Error codes**
...@@ -1101,7 +1160,7 @@ router.pushNamedRoute({ ...@@ -1101,7 +1160,7 @@ router.pushNamedRoute({
``` ```
### pushNamedRoute ### pushNamedRoute
pushNamedRoute(options: NamedRouterOptions, mode: RouterMode): Promise&lt;void&gt; pushNamedRoute(options: router.NamedRouterOptions, mode: router.RouterMode): Promise&lt;void&gt;
Navigates to a page using the named route. This API uses a promise to return the result. Navigates to a page using the named route. This API uses a promise to return the result.
...@@ -1109,10 +1168,10 @@ Navigates to a page using the named route. This API uses a promise to return the ...@@ -1109,10 +1168,10 @@ Navigates to a page using the named route. This API uses a promise to return the
**Parameters** **Parameters**
| Name | Type | Mandatory | Description | | Name | Type | Mandatory| Description |
| ------- | ------------------------------- | ---- | ---------- | | ------- | ------------------------------------------------------------ | ---- | -------------------- |
| options | [NamedRouterOptions](js-apis-router.md#namedrouteroptions10) | Yes | Page routing parameters. | | options | [router.NamedRouterOptions](js-apis-router.md#namedrouteroptions10) | Yes | Page routing parameters. |
| mode | [RouterMode](js-apis-router.md#routermode9) | Yes | Routing mode.| | mode | [router.RouterMode](js-apis-router.md#routermode9) | Yes | Routing mode.|
**Return value** **Return value**
...@@ -1153,9 +1212,9 @@ router.pushNamedRoute({ ...@@ -1153,9 +1212,9 @@ router.pushNamedRoute({
### pushNamedRoute ### pushNamedRoute
pushNamedRoute(options: NamedRouterOptions, mode: RouterMode, callback: AsyncCallback&lt;void&gt;): void pushNamedRoute(options: router.NamedRouterOptions, mode: router.RouterMode, callback: AsyncCallback&lt;void&gt;): void
Navigates to a page using the named route. This API uses an asynchronous callback to return the result. Navigates to a page using the named route. This API uses a promise to return the result.
**System capability**: SystemCapability.ArkUI.ArkUI.Full **System capability**: SystemCapability.ArkUI.ArkUI.Full
...@@ -1163,8 +1222,8 @@ Navigates to a page using the named route. This API uses an asynchronous callbac ...@@ -1163,8 +1222,8 @@ Navigates to a page using the named route. This API uses an asynchronous callbac
| Name | Type | Mandatory | Description | | Name | Type | Mandatory | Description |
| ------- | ------------------------------- | ---- | ---------- | | ------- | ------------------------------- | ---- | ---------- |
| options | [NamedRouterOptions](js-apis-router.md#namedrouteroptions10) | Yes | Page routing parameters. | | options | [router.NamedRouterOptions](js-apis-router.md#namedrouteroptions10) | Yes | Page routing parameters. |
| mode | [RouterMode](js-apis-router.md#routermode9) | Yes | Routing mode.| | mode | [router.RouterMode](js-apis-router.md#routermode9) | Yes | Routing mode.|
| callback | AsyncCallback&lt;void&gt; | Yes | Callback used to return the result. | | callback | AsyncCallback&lt;void&gt; | Yes | Callback used to return the result. |
**Error codes** **Error codes**
...@@ -1200,7 +1259,7 @@ router.pushNamedRoute({ ...@@ -1200,7 +1259,7 @@ router.pushNamedRoute({
### replaceNamedRoute ### replaceNamedRoute
replaceNamedRoute(options: NamedRouterOptions): Promise&lt;void&gt; replaceNamedRoute(options: router.NamedRouterOptions): Promise&lt;void&gt;
Replaces the current page with another one using the named route and destroys the current page. This API uses a promise to return the result. Replaces the current page with another one using the named route and destroys the current page. This API uses a promise to return the result.
...@@ -1208,9 +1267,9 @@ Replaces the current page with another one using the named route and destroys th ...@@ -1208,9 +1267,9 @@ Replaces the current page with another one using the named route and destroys th
**Parameters** **Parameters**
| Name | Type | Mandatory| Description | | Name | Type | Mandatory| Description |
| ------- | ------------------------------- | ---- | ------------------ | | ------- | ------------------------------------------------------------ | ---- | ------------------ |
| options | [NamedRouterOptions](js-apis-router.md#namedrouteroptions10) | Yes | Description of the new page.| | options | [router.NamedRouterOptions](js-apis-router.md#namedrouteroptions10) | Yes | Description of the new page.|
**Return value** **Return value**
...@@ -1224,7 +1283,7 @@ For details about the error codes, see [Router Error Codes](../errorcodes/errorc ...@@ -1224,7 +1283,7 @@ For details about the error codes, see [Router Error Codes](../errorcodes/errorc
| ID | Error Message| | ID | Error Message|
| --------- | ------- | | --------- | ------- |
| 100001 | if UI execution context not found. | | 100001 | if UI execution context not found, only throw in standard system. |
| 100004 | if the named route is not exist. | | 100004 | if the named route is not exist. |
**Example** **Example**
...@@ -1247,9 +1306,9 @@ router.replaceNamedRoute({ ...@@ -1247,9 +1306,9 @@ router.replaceNamedRoute({
### replaceNamedRoute ### replaceNamedRoute
replaceNamedRoute(options: NamedRouterOptions, callback: AsyncCallback&lt;void&gt;): void replaceNamedRoute(options: router.NamedRouterOptions, callback: AsyncCallback&lt;void&gt;): void
Replaces the current page with another one using the named route and destroys the current page. This API uses an asynchronous callback to return the result. Replaces the current page with another one using the named route and destroys the current page. This API uses a promise to return the result.
**System capability**: SystemCapability.ArkUI.ArkUI.Full **System capability**: SystemCapability.ArkUI.ArkUI.Full
...@@ -1257,7 +1316,7 @@ Replaces the current page with another one using the named route and destroys th ...@@ -1257,7 +1316,7 @@ Replaces the current page with another one using the named route and destroys th
| Name | Type | Mandatory| Description | | Name | Type | Mandatory| Description |
| ------- | ------------------------------- | ---- | ------------------ | | ------- | ------------------------------- | ---- | ------------------ |
| options | [NamedRouterOptions](js-apis-router.md#namedrouteroptions10) | Yes | Description of the new page.| | options | [router.NamedRouterOptions](js-apis-router.md#namedrouteroptions10) | Yes | Description of the new page.|
| callback | AsyncCallback&lt;void&gt; | Yes | Callback used to return the result. | | callback | AsyncCallback&lt;void&gt; | Yes | Callback used to return the result. |
**Error codes** **Error codes**
...@@ -1266,7 +1325,7 @@ For details about the error codes, see [Router Error Codes](../errorcodes/errorc ...@@ -1266,7 +1325,7 @@ For details about the error codes, see [Router Error Codes](../errorcodes/errorc
| ID | Error Message| | ID | Error Message|
| --------- | ------- | | --------- | ------- |
| 100001 | if UI execution context not found. | | 100001 | if UI execution context not found, only throw in standard system. |
| 100004 | if the named route is not exist. | | 100004 | if the named route is not exist. |
**Example** **Example**
...@@ -1289,7 +1348,7 @@ router.replaceNamedRoute({ ...@@ -1289,7 +1348,7 @@ router.replaceNamedRoute({
### replaceNamedRoute ### replaceNamedRoute
replaceNamedRoute(options: NamedRouterOptions, mode: RouterMode): Promise&lt;void&gt; replaceNamedRoute(options: router.NamedRouterOptions, mode: router.RouterMode): Promise&lt;void&gt;
Replaces the current page with another one using the named route and destroys the current page. This API uses a promise to return the result. Replaces the current page with another one using the named route and destroys the current page. This API uses a promise to return the result.
...@@ -1297,10 +1356,10 @@ Replaces the current page with another one using the named route and destroys th ...@@ -1297,10 +1356,10 @@ Replaces the current page with another one using the named route and destroys th
**Parameters** **Parameters**
| Name | Type | Mandatory | Description | | Name | Type | Mandatory| Description |
| ------- | ------------------------------- | ---- | ---------- | | ------- | ------------------------------------------------------------ | ---- | -------------------- |
| options | [NamedRouterOptions](js-apis-router.md#namedrouteroptions10) | Yes | Description of the new page. | | options | [router.NamedRouterOptions](js-apis-router.md#namedrouteroptions10) | Yes | Description of the new page. |
| mode | [RouterMode](js-apis-router.md#routermode9) | Yes | Routing mode.| | mode | [router.RouterMode](js-apis-router.md#routermode9) | Yes | Routing mode.|
**Return value** **Return value**
...@@ -1315,7 +1374,7 @@ For details about the error codes, see [Router Error Codes](../errorcodes/errorc ...@@ -1315,7 +1374,7 @@ For details about the error codes, see [Router Error Codes](../errorcodes/errorc
| ID | Error Message| | ID | Error Message|
| --------- | ------- | | --------- | ------- |
| 100001 | if can not get the delegate. | | 100001 | if can not get the delegate, only throw in standard system. |
| 100004 | if the named route is not exist. | | 100004 | if the named route is not exist. |
**Example** **Example**
...@@ -1338,9 +1397,9 @@ router.replaceNamedRoute({ ...@@ -1338,9 +1397,9 @@ router.replaceNamedRoute({
### replaceNamedRoute ### replaceNamedRoute
replaceNamedRoute(options: NamedRouterOptions, mode: RouterMode, callback: AsyncCallback&lt;void&gt;): void replaceNamedRoute(options: router.NamedRouterOptions, mode: router.RouterMode, callback: AsyncCallback&lt;void&gt;): void
Replaces the current page with another one using the named route and destroys the current page. This API uses an asynchronous callback to return the result. Replaces the current page with another one using the named route and destroys the current page. This API uses a promise to return the result.
**System capability**: SystemCapability.ArkUI.ArkUI.Full **System capability**: SystemCapability.ArkUI.ArkUI.Full
...@@ -1348,8 +1407,8 @@ Replaces the current page with another one using the named route and destroys th ...@@ -1348,8 +1407,8 @@ Replaces the current page with another one using the named route and destroys th
| Name | Type | Mandatory | Description | | Name | Type | Mandatory | Description |
| ------- | ------------------------------- | ---- | ---------- | | ------- | ------------------------------- | ---- | ---------- |
| options | [NamedRouterOptions](js-apis-router.md#namedrouteroptions10) | Yes | Description of the new page. | | options | [router.NamedRouterOptions](js-apis-router.md#namedrouteroptions10) | Yes | Description of the new page. |
| mode | [RouterMode](js-apis-router.md#routermode9) | Yes | Routing mode.| | mode | [router.RouterMode](js-apis-router.md#routermode9) | Yes | Routing mode.|
| callback | AsyncCallback&lt;void&gt; | Yes | Callback used to return the result. | | callback | AsyncCallback&lt;void&gt; | Yes | Callback used to return the result. |
**Error codes** **Error codes**
...@@ -1358,7 +1417,7 @@ For details about the error codes, see [Router Error Codes](../errorcodes/errorc ...@@ -1358,7 +1417,7 @@ For details about the error codes, see [Router Error Codes](../errorcodes/errorc
| ID | Error Message| | ID | Error Message|
| --------- | ------- | | --------- | ------- |
| 100001 | if UI execution context not found. | | 100001 | if UI execution context not found, only throw in standard system. |
| 100004 | if the named route is not exist. | | 100004 | if the named route is not exist. |
**Example** **Example**
...@@ -1381,7 +1440,7 @@ router.replaceNamedRoute({ ...@@ -1381,7 +1440,7 @@ router.replaceNamedRoute({
### back ### back
back(options?: RouterOptions ): void back(options?: router.RouterOptions ): void
Returns to the previous page or a specified page. Returns to the previous page or a specified page.
...@@ -1389,9 +1448,9 @@ Returns to the previous page or a specified page. ...@@ -1389,9 +1448,9 @@ Returns to the previous page or a specified page.
**Parameters** **Parameters**
| Name | Type | Mandatory| Description | | Name | Type | Mandatory| Description |
| ------- | ------------------------------- | ---- | ------------------------------------------------------------ | | ------- | ------------------------------------------------------- | ---- | ------------------------------------------------------------ |
| options | [RouterOptions](js-apis-router.md#routeroptions) | No | Description of the page. The **url** parameter indicates the URL of the page to return to. If the specified page does not exist in the page stack, the application does not respond. If no URL is set, the application returns to the previous page, and the page is not rebuilt. The page in the page stack is not reclaimed. It will be reclaimed after being popped up.| | options | [router.RouterOptions](js-apis-router.md#routeroptions) | No | Description of the page. The **url** parameter indicates the URL of the page to return to. If the specified page does not exist in the page stack, the application does not respond. If no URL is set, the application returns to the previous page, and the page is not rebuilt. The page in the page stack is not reclaimed. It will be reclaimed after being popped up.|
**Example** **Example**
...@@ -1439,7 +1498,7 @@ console.log('pages stack size = ' + size); ...@@ -1439,7 +1498,7 @@ console.log('pages stack size = ' + size);
### getState ### getState
getState(): RouterState getState(): router.RouterState
Obtains state information about the current page. Obtains state information about the current page.
...@@ -1463,7 +1522,7 @@ console.log('current path = ' + page.path); ...@@ -1463,7 +1522,7 @@ console.log('current path = ' + page.path);
### showAlertBeforeBackPage ### showAlertBeforeBackPage
showAlertBeforeBackPage(options: EnableAlertOptions): void showAlertBeforeBackPage(options: router.EnableAlertOptions): void
Enables the display of a confirm dialog box before returning to the previous page. Enables the display of a confirm dialog box before returning to the previous page.
...@@ -1471,9 +1530,9 @@ Enables the display of a confirm dialog box before returning to the previous pag ...@@ -1471,9 +1530,9 @@ Enables the display of a confirm dialog box before returning to the previous pag
**Parameters** **Parameters**
| Name | Type | Mandatory | Description | | Name | Type | Mandatory| Description |
| ------- | ---------------------------------------- | ---- | --------- | | ------- | ------------------------------------------------------------ | ---- | ------------------ |
| options | [EnableAlertOptions](js-apis-router.md#enablealertoptions) | Yes | Description of the dialog box.| | options | [router.EnableAlertOptions](js-apis-router.md#enablealertoptions) | Yes | Description of the dialog box.|
**Error codes** **Error codes**
...@@ -1487,13 +1546,15 @@ For details about the error codes, see [Router Error Codes](../errorcodes/errorc ...@@ -1487,13 +1546,15 @@ For details about the error codes, see [Router Error Codes](../errorcodes/errorc
```ts ```ts
let router = uiContext.getRouter(); let router = uiContext.getRouter();
try { router.showAlertBeforeBackPage({
router.showAlertBeforeBackPage({ message: 'Message Info'
message: 'Message Info' });
}); .then(() => {
} catch(error) { // success
console.error(`showAlertBeforeBackPage failed, code is ${error.code}, message is ${error.message}`); })
} .catch(err => {
console.error(`showAlertBeforeBackPage failed, code is ${error.code}, message is ${error.message}`);
})
``` ```
### hideAlertBeforeBackPage ### hideAlertBeforeBackPage
...@@ -1538,7 +1599,7 @@ In the following API examples, you must first use [getPromptAction()](#getprompt ...@@ -1538,7 +1599,7 @@ In the following API examples, you must first use [getPromptAction()](#getprompt
### showToast ### showToast
showToast(options: ShowToastOptions): void showToast(options: promptAction.ShowToastOptions): void
Shows a toast. Shows a toast.
...@@ -1546,9 +1607,9 @@ Shows a toast. ...@@ -1546,9 +1607,9 @@ Shows a toast.
**Parameters** **Parameters**
| Name | Type | Mandatory | Description | | Name | Type | Mandatory| Description |
| ------- | ------------------------------------- | ---- | ------- | | ------- | ------------------------------------------------------------ | ---- | -------------- |
| options | [ShowToastOptions](js-apis-promptAction.md#showtoastoptions) | Yes | Toast options.| | options | [promptAction.ShowToastOptions](js-apis-promptAction.md#showtoastoptions) | Yes | Toast options.|
**Error codes** **Error codes**
...@@ -1574,7 +1635,7 @@ try { ...@@ -1574,7 +1635,7 @@ try {
### showDialog ### showDialog
showDialog(options: ShowDialogOptions, callback: AsyncCallback&lt;ShowDialogSuccessResponse&lt;): void showDialog(options: promptAction.ShowDialogOptions, callback: AsyncCallback&lt;promptAction.ShowDialogSuccessResponse&gt;): void
Shows a dialog box. This API uses an asynchronous callback to return the result. Shows a dialog box. This API uses an asynchronous callback to return the result.
...@@ -1582,10 +1643,10 @@ Shows a dialog box. This API uses an asynchronous callback to return the result. ...@@ -1582,10 +1643,10 @@ Shows a dialog box. This API uses an asynchronous callback to return the result.
**Parameters** **Parameters**
| Name | Type | Mandatory | Description | | Name | Type | Mandatory| Description |
| -------- | ---------------------------------------- | ---- | ------------ | | -------- | ------------------------------------------------------------ | ---- | ------------------------ |
| options | [ShowDialogOptions](js-apis-promptAction.md#showdialogoptions) | Yes | Dialog box options.| | options | [promptAction.ShowDialogOptions](js-apis-promptAction.md#showdialogoptions) | Yes | Dialog box options.|
| callback | AsyncCallback&lt;[ShowDialogSuccessResponse](js-apis-promptAction.md#showdialogsuccessresponse)&gt; | Yes | Callback used to return the dialog box response result. | | callback | AsyncCallback&lt;[promptAction.ShowDialogSuccessResponse](js-apis-promptAction.md#showdialogsuccessresponse)&gt; | Yes | Callback used to return the dialog box response result. |
**Error codes** **Error codes**
...@@ -1627,7 +1688,7 @@ try { ...@@ -1627,7 +1688,7 @@ try {
### showDialog ### showDialog
showDialog(options: ShowDialogOptions): Promise&lt;ShowDialogSuccessResponse&gt; showDialog(options: promptAction.ShowDialogOptions): Promise&lt;promptAction.ShowDialogSuccessResponse&gt;
Shows a dialog box. This API uses a promise to return the result synchronously. Shows a dialog box. This API uses a promise to return the result synchronously.
...@@ -1635,15 +1696,15 @@ Shows a dialog box. This API uses a promise to return the result synchronously. ...@@ -1635,15 +1696,15 @@ Shows a dialog box. This API uses a promise to return the result synchronously.
**Parameters** **Parameters**
| Name | Type | Mandatory | Description | | Name | Type | Mandatory| Description |
| ------- | --------------------------------------- | ---- | ------ | | ------- | ------------------------------------------------------------ | ---- | ------------ |
| options | [ShowDialogOptions](js-apis-promptAction.md#showdialogoptions) | Yes | Dialog box options.| | options | [promptAction.ShowDialogOptions](js-apis-promptAction.md#showdialogoptions) | Yes | Dialog box options.|
**Return value** **Return value**
| Type | Description | | Type | Description |
| ---------------------------------------- | -------- | | ------------------------------------------------------------ | ---------------- |
| Promise&lt;[ShowDialogSuccessResponse](js-apis-promptAction.md#showdialogsuccessresponse)&gt; | Promise used to return the dialog box response result.| | Promise&lt;[promptAction.ShowDialogSuccessResponse](js-apis-promptAction.md#showdialogsuccessresponse)&gt; | Promise used to return the dialog box response result.|
**Error codes** **Error codes**
...@@ -1685,7 +1746,7 @@ try { ...@@ -1685,7 +1746,7 @@ try {
### showActionMenu ### showActionMenu
showActionMenu(options: ActionMenuOptions, callback: AsyncCallback&lt;ActionMenuSuccessResponse&gt;):void showActionMenu(options: promptAction.ActionMenuOptions, callback:promptAction.ActionMenuSuccessResponse):void
Shows an action menu. This API uses an asynchronous callback to return the result. Shows an action menu. This API uses an asynchronous callback to return the result.
...@@ -1693,10 +1754,10 @@ Shows an action menu. This API uses an asynchronous callback to return the resul ...@@ -1693,10 +1754,10 @@ Shows an action menu. This API uses an asynchronous callback to return the resul
**Parameters** **Parameters**
| Name | Type | Mandatory | Description | | Name | Type | Mandatory| Description |
| -------- | ---------------------------------------- | ---- | --------- | | -------- | ------------------------------------------------------------ | ---- | ------------------ |
| options | [ActionMenuOptions](js-apis-promptAction.md#actionmenuoptions) | Yes | Action menu options. | | options | [promptAction.ActionMenuOptions](js-apis-promptAction.md#actionmenuoptions) | Yes | Action menu options. |
| callback | AsyncCallback&lt;[ActionMenuSuccessResponse](js-apis-promptAction.md#actionmenusuccessresponse)> | Yes | Callback used to return the action menu response result.| | callback | [promptAction.ActionMenuSuccessResponse](js-apis-promptAction.md#actionmenusuccessresponse) | Yes | Callback used to return the action menu response result.|
**Error codes** **Error codes**
...@@ -1737,7 +1798,7 @@ try { ...@@ -1737,7 +1798,7 @@ try {
### showActionMenu ### showActionMenu
showActionMenu(options: ActionMenuOptions): Promise&lt;ActionMenuSuccessResponse&gt; showActionMenu(options: promptAction.ActionMenuOptions): Promise&lt;promptAction.ActionMenuSuccessResponse&gt;
Shows an action menu. This API uses a promise to return the result synchronously. Shows an action menu. This API uses a promise to return the result synchronously.
...@@ -1745,15 +1806,15 @@ Shows an action menu. This API uses a promise to return the result synchronously ...@@ -1745,15 +1806,15 @@ Shows an action menu. This API uses a promise to return the result synchronously
**Parameters** **Parameters**
| Name | Type | Mandatory | Description | | Name | Type | Mandatory| Description |
| ------- | --------------------------------------- | ---- | ------- | | ------- | ------------------------------------------------------------ | ---- | -------------- |
| options | [ActionMenuOptions](js-apis-promptAction.md#actionmenuoptions) | Yes | Action menu options.| | options | [promptAction.ActionMenuOptions](js-apis-promptAction.md#actionmenuoptions) | Yes | Action menu options.|
**Return value** **Return value**
| Type | Description | | Type | Description |
| ---------------------------------------- | ------- | | ------------------------------------------------------------ | -------------- |
| Promise&lt;[ActionMenuSuccessResponse](js-apis-promptAction.md#actionmenusuccessresponse)&gt; | Promise used to return the action menu response result.| | Promise&lt;[promptAction.ActionMenuSuccessResponse](js-apis-promptAction.md#actionmenusuccessresponse)&gt; | Promise used to return the action menu response result.|
**Error codes** **Error codes**
......
...@@ -57,7 +57,7 @@ struct Index { ...@@ -57,7 +57,7 @@ struct Index {
Row() { Row() {
Column() { Column() {
Image((<LayeredDrawableDescriptor> (this.resManager.getDrawableDescriptor($r('app.media.icon').id)))) Image((<LayeredDrawableDescriptor> (this.resManager.getDrawableDescriptor($r('app.media.icon').id))))
Image(((<LayeredDrawableDescriptor> (this.resManager.getDrawableDescriptor($r('app.media.drawable') Image(((<LayeredDrawableDescriptor> (this.resManager.getDrawableDescriptor($r('app.media.icon')
.id))).getForeground()).getPixelMap()) .id))).getForeground()).getPixelMap())
}.height('50%') }.height('50%')
}.width('50%') }.width('50%')
...@@ -80,7 +80,8 @@ Obtains this **pixelMap** object. ...@@ -80,7 +80,8 @@ Obtains this **pixelMap** object.
**Example** **Example**
```ts ```ts
pixmap: PixelMap = (<DrawableDescriptor> (this.resManager.getDrawableDescriptor($r('app.media.icon') let resManager = getContext().resourceManager
let pixmap: PixelMap = (<DrawableDescriptor> (resManager.getDrawableDescriptor($r('app.media.icon')
.id))).getPixelMap(); .id))).getPixelMap();
``` ```
...@@ -99,7 +100,8 @@ Obtains the **pixelMap** object where the foreground, background, and mask are b ...@@ -99,7 +100,8 @@ Obtains the **pixelMap** object where the foreground, background, and mask are b
**Example** **Example**
```ts ```ts
pixmap: PixelMap = (<LayeredDrawableDescriptor> (this.resManager.getDrawableDescriptor($r('app.media.drawable') let resManager = getContext().resourceManager
let pixmap: PixelMap = (<LayeredDrawableDescriptor> (resManager.getDrawableDescriptor($r('app.media.icon')
.id))).getPixelMap(); .id))).getPixelMap();
``` ```
...@@ -118,7 +120,8 @@ Obtains the **DrawableDescriptor** object of the foreground. ...@@ -118,7 +120,8 @@ Obtains the **DrawableDescriptor** object of the foreground.
**Example** **Example**
```ts ```ts
drawable: DrawableDescriptor = (<LayeredDrawableDescriptor> (this.resManager.getDrawableDescriptor($r('app.media.drawable') let resManager = getContext().resourceManager
let drawable: DrawableDescriptor = (<LayeredDrawableDescriptor> (resManager.getDrawableDescriptor($r('app.media.icon')
.id))).getForeground(); .id))).getForeground();
``` ```
...@@ -137,7 +140,8 @@ Obtains the **DrawableDescriptor** object of the background. ...@@ -137,7 +140,8 @@ Obtains the **DrawableDescriptor** object of the background.
**Example** **Example**
```ts ```ts
drawable: DrawableDescriptor = (<LayeredDrawableDescriptor> (this.resManager.getDrawableDescriptor($r('app.media.drawable') let resManager = getContext().resourceManager
let drawable: DrawableDescriptor = (<LayeredDrawableDescriptor> (resManager.getDrawableDescriptor($r('app.media.icon')
.id))).getBackground(); .id))).getBackground();
``` ```
...@@ -156,6 +160,26 @@ Obtains the **DrawableDescriptor** object of the mask. ...@@ -156,6 +160,26 @@ Obtains the **DrawableDescriptor** object of the mask.
**Example** **Example**
```ts ```ts
drawable: DrawableDescriptor = (<LayeredDrawableDescriptor> (this.resManager.getDrawableDescriptor($r('app.media.drawable') let resManager = getContext().resourceManager
let drawable: DrawableDescriptor = (<LayeredDrawableDescriptor> (resManager.getDrawableDescriptor($r('app.media.icon')
.id))).getMask(); .id))).getMask();
``` ```
## LayeredDrawableDescriptor.getMaskClipPath
static getMaskClipPath(): string
Obtains the built-in clipping path parameters of the system. It is a static method of **LayeredDrawableDescriptor**.
**System capability**: SystemCapability.ArkUI.ArkUI.Full
**Return value**
| Type | Description |
| ---------------------------------------- | -------------------- |
| string | String of the clipping path.|
**Example**
```ts
Image($r('app.media.icon'))
.width('200px').height('200px')
.clip(new Path({commands:LayeredDrawableDescriptor.getMaskClipPath()}))
```
...@@ -41,7 +41,7 @@ Since API version 9, this API is supported in ArkTS widgets. ...@@ -41,7 +41,7 @@ Since API version 9, this API is supported in ArkTS widgets.
**System capability**: SystemCapability.ArkUI.ArkUI.Full **System capability**: SystemCapability.ArkUI.ArkUI.Full
| Name | Description: | | Name | Description |
| ------------------- | ------------------------------------------------------------ | | ------------------- | ------------------------------------------------------------ |
| Linear | The animation speed keeps unchanged. | | Linear | The animation speed keeps unchanged. |
| Ease | The animation starts slowly, accelerates, and then slows down towards the end. The cubic-bezier curve (0.25, 0.1, 0.25, 1.0) is used.| | Ease | The animation starts slowly, accelerates, and then slows down towards the end. The cubic-bezier curve (0.25, 0.1, 0.25, 1.0) is used.|
...@@ -78,7 +78,7 @@ Creates a step curve. ...@@ -78,7 +78,7 @@ Creates a step curve.
| Name| Type | Mandatory| Description | | Name| Type | Mandatory| Description |
| ------ | ------- | ----| ------------------------------------------------------------ | | ------ | ------- | ----| ------------------------------------------------------------ |
| count | number | Yes | Number of steps. The value must be a positive integer.<br>Value range: [0, +∞)<br>**NOTE**<br>A value less than 0 evaluates to the value **0**.| | count | number | Yes | Number of steps. The value must be a positive integer.<br>Value range: [1, +∞)<br>**NOTE**<br>A value less than 1 evaluates to the value **1**.|
| end | boolean | Yes | Whether jumping occurs when the interpolation ends.<br>- **true**: Jumping occurs when the interpolation ends.<br>- **false**: Jumping occurs when the interpolation starts.| | end | boolean | Yes | Whether jumping occurs when the interpolation ends.<br>- **true**: Jumping occurs when the interpolation ends.<br>- **false**: Jumping occurs when the interpolation starts.|
**Return value** **Return value**
...@@ -174,7 +174,7 @@ Creates a spring animation curve. If multiple spring animations are applied to t ...@@ -174,7 +174,7 @@ Creates a spring animation curve. If multiple spring animations are applied to t
| Name | Type | Mandatory | Description | | Name | Type | Mandatory | Description |
| --------- | ------ | ---- | ----- | | --------- | ------ | ---- | ----- |
| response | number | No | Duration of one complete oscillation.<br>Default value: **0.55**<br>Unit: second<br>Value range: [0, +∞)<br>**NOTE**<br>A value less than 0 evaluates to the default value **0.55**.| | response | number | No | Duration of one complete oscillation.<br>Default value: **0.55**<br>Unit: second<br>Value range: [0, +∞)<br>**NOTE**<br>A value less than 0 evaluates to the default value **0.55**.|
| dampingFraction | number | No | Damping coefficient.<br>**0**: undamped. In this case, the spring oscillates forever.<br>> 0 and < 1: underdamped. In this case, the spring overshoots the equilibrium position.<br>**1**: critically damped.<br>> 1: overdamped. In this case, the spring approaches equilibrium gradually.<br>Default value: **0.825**<br>Unit: second<br>Value range: [0, +∞)<br>**NOTE**<br>A value less than 0 evaluates to the default value **0.55**.| | dampingFraction | number | No | Damping coefficient.<br>**0**: undamped. In this case, the spring oscillates forever.<br>> 0 and < 1: underdamped. In this case, the spring overshoots the equilibrium position.<br>**1**: critically damped.<br>> 1: overdamped. In this case, the spring approaches equilibrium gradually.<br>Default value: **0.825**<br>Unit: second<br>Value range: [0, +∞)<br>**NOTE**<br>A value less than 0 evaluates to the default value **0.825**.|
| overlapDuration | number | No | Duration for animations to overlap, in seconds. When animations overlap, the **response** values of these animations will transit smoothly over this duration if they are different.<br>Default value: **0**<br>Unit: second<br>Value range: [0, +∞)<br>**NOTE**<br>A value less than 0 evaluates to the default value **0**.<br>The spring animation curve is physics-based. Its duration depends on the **springMotion** parameters and the previous velocity, rather than the **duration** parameter in [animation](../arkui-ts/ts-animatorproperty.md) or [animateTo](../arkui-ts/ts-explicit-animation.md). The time cannot be normalized. Therefore, the interpolation cannot be obtained using the **interpolate** function of the curve.| | overlapDuration | number | No | Duration for animations to overlap, in seconds. When animations overlap, the **response** values of these animations will transit smoothly over this duration if they are different.<br>Default value: **0**<br>Unit: second<br>Value range: [0, +∞)<br>**NOTE**<br>A value less than 0 evaluates to the default value **0**.<br>The spring animation curve is physics-based. Its duration depends on the **springMotion** parameters and the previous velocity, rather than the **duration** parameter in [animation](../arkui-ts/ts-animatorproperty.md) or [animateTo](../arkui-ts/ts-explicit-animation.md). The time cannot be normalized. Therefore, the interpolation cannot be obtained using the **interpolate** function of the curve.|
...@@ -209,7 +209,7 @@ Creates a responsive spring animation curve. It is a special case of [springMoti ...@@ -209,7 +209,7 @@ Creates a responsive spring animation curve. It is a special case of [springMoti
| --------- | ------ | ---- | ----- | | --------- | ------ | ---- | ----- |
| response | number | No | See **response** in **springMotion**.<br>Default value: **0.15**<br>Unit: second<br>Value range: [0, +∞)<br>**NOTE**<br>A value less than 0 evaluates to the default value **0.15**.| | response | number | No | See **response** in **springMotion**.<br>Default value: **0.15**<br>Unit: second<br>Value range: [0, +∞)<br>**NOTE**<br>A value less than 0 evaluates to the default value **0.15**.|
| dampingFraction | number | No | See **dampingFraction** in **springMotion**.<br>Default value: **0.86**<br>Unit: second<br>Value range: [0, +∞)<br>**NOTE**<br>A value less than 0 evaluates to the default value **0.86**.| | dampingFraction | number | No | See **dampingFraction** in **springMotion**.<br>Default value: **0.86**<br>Unit: second<br>Value range: [0, +∞)<br>**NOTE**<br>A value less than 0 evaluates to the default value **0.86**.|
| overlapDuration | number | No | See **overlapDuration** in **springMotion**.<br>Default value: **0.25**<br>Unit: second<br>Value range: [0, +∞)<br>**NOTE**<br>A value less than 0 evaluates to the default value **0.25**.<br> To apply custom settings for a spring animation, you are advised to use **springMotion**. When using **responsiveSpringMotion**, you are advised to retain the default settings.<br>The duration of the responsive spring animation depends on the **responsiveSpringMotion** parameters and the previous velocity, rather than the **duration** parameter in [animation](../arkui-ts/ts-animatorproperty.md) or [animateTo](../arkui-ts/ts-explicit-animation.md). In addition, the interpolation cannot be obtained using the **interpolate** function of the curve. | | overlapDuration | number | No | See **overlapDuration** in **springMotion**.<br>Default value: **0.25**<br>Unit: second<br>Value range: [0, +∞)<br>**NOTE**<br>A value less than 0 evaluates to the default value **0.25**.<br> To apply custom settings for a spring animation, you are advised to use **springMotion**. When using **responsiveSpringMotion**, you are advised to retain the default settings.<br>The duration of the responsive spring animation depends on the **responsiveSpringMotion** parameters and the previous velocity, rather than the **duration** parameter in [animation](../arkui-ts/ts-animatorproperty.md) or [animateTo](../arkui-ts/ts-explicit-animation.md). In addition, the interpolation cannot be obtained using the **interpolate** function of the curve.|
**Return value** **Return value**
...@@ -237,16 +237,16 @@ Creates an interpolating spring curve animated from 0 to 1. The actual animation ...@@ -237,16 +237,16 @@ Creates an interpolating spring curve animated from 0 to 1. The actual animation
**Parameters** **Parameters**
| Name | Type | Mandatory | Description | | Name | Type | Mandatory | Description |
| --------- | ------ | ---- | ----- | | --------- | ------ | ---- | ----- |
| velocity | number | Yes | Initial velocity. It is applied by external factors to the spring animation, designed to help ensure the smooth transition from the previous motion state. The velocity is the normalized velocity, and its value is equal to the actual velocity at the beginning of the animation divided by the animation attribute change value.| | velocity | number | Yes | Initial velocity. It is applied by external factors to the spring animation, designed to help ensure the smooth transition from the previous motion state. The velocity is the normalized velocity, and its value is equal to the actual velocity at the beginning of the animation divided by the animation attribute change value.<br>Value range: (-∞, +∞)|
| mass | number | Yes | Mass, which influences the inertia in the spring system. The greater the mass, the greater the amplitude of the oscillation, and the slower the speed of restoring to the equilibrium position.| | mass | number | Yes | Mass, which influences the inertia in the spring system. The greater the mass, the greater the amplitude of the oscillation, and the slower the speed of restoring to the equilibrium position.<br>Value range: [0, +∞)<br>**NOTE**<br>A value less than 0 evaluates to the value **1**.|
| stiffness | number | Yes | Stiffness. It is the degree to which an object deforms by resisting the force applied. In an elastic system, the greater the stiffness, the stronger the ability to resist deformation, and the faster the speed of restoring to the equilibrium position.| | stiffness | number | Yes | Stiffness. It is the degree to which an object deforms by resisting the force applied. In an elastic system, the greater the stiffness, the stronger the ability to resist deformation, and the faster the speed of restoring to the equilibrium position.<br>Value range: [0, +∞)<br>**NOTE**<br>A value less than 0 evaluates to the value **1**.|
| damping | number | Yes | Damping. It is a pure number and has no real physical meaning. It is used to describe the oscillation and attenuation of the system after being disturbed. The larger the damping, the smaller the number of oscillations of elastic motion, and the smaller the oscillation amplitude.| | damping | number | Yes | Damping. It is a pure number and has no real physical meaning. It is used to describe the oscillation and attenuation of the system after being disturbed. The larger the damping, the smaller the number of oscillations of elastic motion, and the smaller the oscillation amplitude.<br>Value range: [0, +∞)<br>**NOTE**<br>A value less than 0 evaluates to the value **1**.|
**Return value** **Return value**
| Type | Description | | Type | Description |
| ---------------------------------- | ---------------- | | ---------------------------------- | ---------------- |
| [ICurve](#icurve)| Interpolation curve.| | [ICurve](#icurve)| Curve.<br>**NOTE**<br>The spring animation curve is physics-based. Its duration depends on the** interpolatingSpring** parameters, rather than the **duration** parameter in [animation](../arkui-ts/ts-animatorproperty.md) or [animateTo](../arkui-ts/ts-explicit-animation.md). The time cannot be normalized. Therefore, the interpolation cannot be obtained using the [interpolate](#interpolate9) function of the curve.|
**Example** **Example**
...@@ -279,10 +279,10 @@ Creates a custom curve. ...@@ -279,10 +279,10 @@ Creates a custom curve.
```ts ```ts
import Curves from '@ohos.curves' import Curves from '@ohos.curves'
interpolate(fraction) { let interpolate = function(fraction) {
return Math.sqrt(fraction); return Math.sqrt(fraction)
} }
private curve = Curves.customCurve(this.interpolate) // Create a custom curve. let curve = Curves.customCurve(interpolate) // Create a custom interpolation curve.
``` ```
...@@ -316,7 +316,7 @@ Since API version 9, this API is supported in ArkTS widgets. ...@@ -316,7 +316,7 @@ Since API version 9, this API is supported in ArkTS widgets.
```ts ```ts
import Curves from '@ohos.curves' import Curves from '@ohos.curves'
let curve = Curves.initCurve(Curve.EaseIn) // Create an ease-in curve. let curveValue = Curves.initCurve(Curve.EaseIn) // Create an ease-in curve.
let value: number = curve.interpolate(0.5) // Calculate the interpolation for half of the time. let value: number = curve.interpolate(0.5) // Calculate the interpolation for half of the time.
``` ```
......
...@@ -54,7 +54,7 @@ struct FontExample { ...@@ -54,7 +54,7 @@ struct FontExample {
// Both familyName and familySrc support the string type. // Both familyName and familySrc support the string type.
font.registerFont({ font.registerFont({
familyName: 'medium', familyName: 'medium',
familySrc: '/font/medium.ttf' familySrc: '/font/medium.ttf' // The font file is at the same level as the pages directory.
}) })
// Both familyName and familySrc support the Resource type. // Both familyName and familySrc support the Resource type.
...@@ -138,7 +138,7 @@ Obtains information about a system font based on the font name. ...@@ -138,7 +138,7 @@ Obtains information about a system font based on the font name.
| ---------------- | ---------------------------- | | ---------------- | ---------------------------- |
| FontInfo | Information about the system font. | | FontInfo | Information about the system font. |
## FontInfo ## FontInfo<sup>10+</sup>
**System capability**: SystemCapability.ArkUI.ArkUI.Full **System capability**: SystemCapability.ArkUI.ArkUI.Full
...@@ -170,7 +170,7 @@ struct FontExample { ...@@ -170,7 +170,7 @@ struct FontExample {
Column() { Column() {
Button("getFontByName") Button("getFontByName")
.onClick(() => { .onClick(() => {
this.fontInfo = font.getFontByName('HarmonyOS Sans Italic') this.fontInfo = font.getFontByName('Sans Italic')
console.log("getFontByName(): path = " + this.fontInfo.path) console.log("getFontByName(): path = " + this.fontInfo.path)
console.log("getFontByName(): postScriptName = " + this.fontInfo.postScriptName) console.log("getFontByName(): postScriptName = " + this.fontInfo.postScriptName)
console.log("getFontByName(): fullName = " + this.fontInfo.fullName) console.log("getFontByName(): fullName = " + this.fontInfo.fullName)
......
...@@ -22,7 +22,7 @@ Since API version 9, this API is supported in ArkTS widgets. ...@@ -22,7 +22,7 @@ Since API version 9, this API is supported in ArkTS widgets.
| Name| Type| Mandatory| Description| | Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- | | -------- | -------- | -------- | -------- |
| group | string | No| Group name.| | group | string | No| Group name.<br>**NOTE**<br>If there are multiple check box groups with the same group name, only the first check box group takes effect.|
## Attributes ## Attributes
......
...@@ -303,7 +303,7 @@ Provides the text style information. ...@@ -303,7 +303,7 @@ Provides the text style information.
| fontSize | [Length](ts-types.md#length) \| number | No| Font size.<br>Default value: **16fp**| | fontSize | [Length](ts-types.md#length) \| number | No| Font size.<br>Default value: **16fp**|
| fontStyle | [FontStyle](ts-appendix-enums.md#fontstyle) | No| Font style.<br>Default value: **FontStyle.Normal**| | fontStyle | [FontStyle](ts-appendix-enums.md#fontstyle) | No| Font style.<br>Default value: **FontStyle.Normal**|
| fontWeight | [FontWeight](ts-appendix-enums.md#fontweight) \| number \| string | No| Font weight.<br>For the number type, the value ranges from 100 to 900, at an interval of 100. A larger value indicates a heavier font weight. The default value is **400**.<br>For the string type, only strings of the number type are supported, for example, **"400"**, **"bold"**, **"bolder"**, **"lighter"**, **"regular"**, and **"medium"**, which correspond to the enumerated values in **FontWeight**.<br>Default value: **FontWeight.Normal**| | fontWeight | [FontWeight](ts-appendix-enums.md#fontweight) \| number \| string | No| Font weight.<br>For the number type, the value ranges from 100 to 900, at an interval of 100. A larger value indicates a heavier font weight. The default value is **400**.<br>For the string type, only strings of the number type are supported, for example, **"400"**, **"bold"**, **"bolder"**, **"lighter"**, **"regular"**, and **"medium"**, which correspond to the enumerated values in **FontWeight**.<br>Default value: **FontWeight.Normal**|
| fontFamily | [ResourceStr](ts-types.md#resourcestr) \| number \| string | No| Font family. Default value: **'HarmonyOS Sans'**.<br>Currently, only the default font is supported.<br>Default font: **'HarmonyOS Sans'**| | fontFamily | [ResourceStr](ts-types.md#resourcestr) \| number \| string | No| Font family. The HarmonyOS Sans font and [register custom fonts](../apis/js-apis-font.md) are supported.<br>Default font: **'HarmonyOS Sans'**|
| decoration | {<br>type: [TextDecorationType](ts-appendix-enums.md#textdecorationtype),<br>color?: [ResourceColor](ts-types.md#resourcecolor)<br>} | No| Style and color of the text decorative line.<br>Default value: {<br>type: TextDecorationType.None,<br>color: Color.Black<br>}| | decoration | {<br>type: [TextDecorationType](ts-appendix-enums.md#textdecorationtype),<br>color?: [ResourceColor](ts-types.md#resourcecolor)<br>} | No| Style and color of the text decorative line.<br>Default value: {<br>type: TextDecorationType.None,<br>color: Color.Black<br>}|
......
...@@ -58,6 +58,12 @@ struct SpanExample { ...@@ -58,6 +58,12 @@ struct SpanExample {
build() { build() {
Flex({ direction: FlexDirection.Column, alignItems: ItemAlign.Start, justifyContent: FlexAlign.SpaceBetween }) { Flex({ direction: FlexDirection.Column, alignItems: ItemAlign.Start, justifyContent: FlexAlign.SpaceBetween }) {
Text('Basic Usage').fontSize(9).fontColor(0xCCCCCC) Text('Basic Usage').fontSize(9).fontColor(0xCCCCCC)
Text() {
Span('In Line')
Span(' Component')
Span(' !')
}
Text() { Text() {
Span('This is the Span component').fontSize(12).textCase(TextCase.Normal) Span('This is the Span component').fontSize(12).textCase(TextCase.Normal)
.decoration({ type: TextDecorationType.None, color: Color.Red }) .decoration({ type: TextDecorationType.None, color: Color.Red })
...@@ -118,4 +124,4 @@ struct SpanExample { ...@@ -118,4 +124,4 @@ struct SpanExample {
} }
``` ```
![span](figures/span.png) ![Span](figures/span.png)
...@@ -45,8 +45,8 @@ Among the [universal attributes](ts-universal-attributes-size.md) and [universal ...@@ -45,8 +45,8 @@ Among the [universal attributes](ts-universal-attributes-size.md) and [universal
| selectedBackgroundColor<sup>10+</sup> | [ResourceColor](ts-types.md#resourcecolor) | Background color of the selected text.<br>If the opacity is not set, the color is opaque. For example, **0x80000000** indicates black with 50% opacity.| | selectedBackgroundColor<sup>10+</sup> | [ResourceColor](ts-types.md#resourcecolor) | Background color of the selected text.<br>If the opacity is not set, the color is opaque. For example, **0x80000000** indicates black with 50% opacity.|
| caretStyle<sup>10+</sup> | {<br>width: [Length](ts-types.md#length)<br>} | Caret style. | | caretStyle<sup>10+</sup> | {<br>width: [Length](ts-types.md#length)<br>} | Caret style. |
| caretPosition<sup>10+</sup> | number | Caret position.| | caretPosition<sup>10+</sup> | number | Caret position.|
| showUnit<sup>10+</sup> | [CustomBuilder](ts-types.md#CustomBuilder8) | Unit for content in the component.<br>By default, there is no unit.| | showUnit<sup>10+</sup> | [CustomBuilder](ts-types.md#CustomBuilder8) | Unit for content in the component.<br>By default, there is no unit.|
| showError<sup>10+</sup> | string \| undefined | Error text displayed when an error occurs.<br>By default, no error text is displayed.| | showError<sup>10+</sup> | string \| undefined | Error message displayed when an error occurs.<br>By default, no error message is displayed.<br>**NOTE**<br>If the parameter type is string and the input content does not comply with specifications, the error message is displayed. If the parameter type is undefined, no error message is displayed. See [Example 2](#example-2).|
| showUnderline<sup>10+</sup> | boolean | Whether to show an underline.<br>Default value: **false**| | showUnderline<sup>10+</sup> | boolean | Whether to show an underline.<br>Default value: **false**|
| passwordIcon<sup>10+</sup> | [PasswordIcon](#passwordicon10) | Password icon to display at the end of the password text box.<br>By default, the system-provided icon is used.| | passwordIcon<sup>10+</sup> | [PasswordIcon](#passwordicon10) | Password icon to display at the end of the password text box.<br>By default, the system-provided icon is used.|
| enableKeyboardOnFocus<sup>10+</sup> | boolean | Whether to enable the input method when the component obtains focus.<br>Default value: **true** | | enableKeyboardOnFocus<sup>10+</sup> | boolean | Whether to enable the input method when the component obtains focus.<br>Default value: **true** |
...@@ -129,7 +129,7 @@ Sets the position of the caret. ...@@ -129,7 +129,7 @@ Sets the position of the caret.
| value | number | Yes | Length from the start of the string to the position where the caret is located.| | value | number | Yes | Length from the start of the string to the position where the caret is located.|
### setTextSelection<sup>10+</sup> ### setTextSelection<sup>10+</sup>
setTextSelection(selectionStart: number, selectionStart: number): void setTextSelection(selectionStart: number, selectionEnd: number): void
Sets the text selection area, which will be highlighted. Sets the text selection area, which will be highlighted.
...@@ -248,17 +248,20 @@ struct TextInputExample { ...@@ -248,17 +248,20 @@ struct TextInputExample {
### Example 2 ### Example 2
```ts ```ts
// xxx.ets
@Entry @Entry
@Component @Component
struct TextInputExample { struct TextInputExample {
@State PassWordSrc1:Resource=$r('app.media.icon') @State PassWordSrc1: Resource = $r('app.media.onIcon')
@State PassWordSrc2:Resource=$r('app.media.icon') @State PassWordSrc2: Resource = $r('app.media.offIcon')
@State TextError: string = undefined
@State Text: string = ''
@State NameText: string = 'test'
@Builder itemEnd() { @Builder itemEnd() {
Select([{ value: 'KB' }, Select([{ value: 'KB' },
{ value: 'MB' }, { value: 'MB' },
{ value: 'GB'}, { value: 'GB' },
{ value: 'TB',}]) { value: 'TB', }])
.height("48vp") .height("48vp")
.borderRadius(0) .borderRadius(0)
.selected(2) .selected(2)
...@@ -269,30 +272,49 @@ struct TextInputExample { ...@@ -269,30 +272,49 @@ struct TextInputExample {
.selectedOptionFont({ size: 20, weight: 400 }) .selectedOptionFont({ size: 20, weight: 400 })
.optionFont({ size: 20, weight: 400 }) .optionFont({ size: 20, weight: 400 })
.backgroundColor(Color.Transparent) .backgroundColor(Color.Transparent)
.responseRegion({height:"40vp",width:"80%",x:'10%',y:'6vp'}) .responseRegion({ height: "40vp", width: "80%", x: '10%', y: '6vp' })
.onSelect((index: number) => { .onSelect((index: number) => {
console.info('Select:' + index) console.info('Select:' + index)
}) })
} }
build() { build() {
Column() { Column({ space: 20 }) {
// Customize the password icon. // Customize the password icon.
TextInput({ placeholder: 'user define password icon' }) TextInput({ placeholder: 'Custom password icon' })
.type(InputType.Password) .type(InputType.Password)
.width(400) .width(380)
.height(60) .height(60)
.passwordIcon({onIconSrc:this.PassWordSrc1,offIconSrc : this.PassWordSrc2}) .passwordIcon({ onIconSrc: this.PassWordSrc1, offIconSrc: this.PassWordSrc2 })
// Show an underline. // Show an underline.
TextInput({ placeholder: 'underline style' }) TextInput({ placeholder: 'Underline style' })
.showUnderline(true) .showUnderline(true)
.width(400) .width(380)
.height(60) .height(60)
.showError('Error') .showError('Error')
.showUnit(this.itemEnd.bind(this)) .showUnit(this.itemEnd.bind(this))
Text (`User name: ${this.Text}`)
.width('95%')
TextInput({ placeholder: 'Enter user name', text: this.Text })
.showUnderline(true)
.width(380)
.showError(this.TextError)
.onChange((value: string) => {
this.Text = value
})
.onSubmit(() => {// If the entered user name is incorrect, the text box will be cleared and the error message will be displayed.
if (this.Text == this.NameText) {
this.TextError = undefined
} else {
this.TextError ='Incorrect user name.'
this.Text = ''
}
})
}.width('100%') }.width('100%')
} }
} }
``` ```
![showUnit](figures/showUnit.png) ![TextInputError](figures/TextInputError.PNG)
...@@ -45,10 +45,12 @@ In addition to the [universal events](ts-universal-events-click.md), the followi ...@@ -45,10 +45,12 @@ In addition to the [universal events](ts-universal-events-click.md), the followi
## TimePickerResult ## TimePickerResult
| Name | Type | Description | Describes a time in 24-hour format.
| ------ | ------ | ------- |
| hour | number | Hour portion of the selected time.| | Name | Type| Description |
| minute | number | Minute portion of the selected time.| | ------ | -------- | ----------------------------------- |
| hour | number | Hour portion of the selected time.<br>Value range: [0-23]|
| minute | number | Minute portion of the selected time.<br>Value range: [0-59]|
## Example ## Example
......
...@@ -158,7 +158,7 @@ The **Font** type is used to set the text style. ...@@ -158,7 +158,7 @@ The **Font** type is used to set the text style.
| ------ | ---------------------------------------- | ---- | ---------------------------------------- | | ------ | ---------------------------------------- | ---- | ---------------------------------------- |
| size | [Length](#length) | No | Font size. If the value is of the number type, the unit fp is used. The value cannot be a percentage.<br>Default value: **16.0** | | size | [Length](#length) | No | Font size. If the value is of the number type, the unit fp is used. The value cannot be a percentage.<br>Default value: **16.0** |
| weight | [FontWeight](ts-appendix-enums.md#fontweight) \| number \| string | No | Font weight. For the number type, the value ranges from 100 to 900, at an interval of 100. A larger value indicates a thicker font.<br>Default value: **400** \| **FontWeight.Normal** | | weight | [FontWeight](ts-appendix-enums.md#fontweight) \| number \| string | No | Font weight. For the number type, the value ranges from 100 to 900, at an interval of 100. A larger value indicates a thicker font.<br>Default value: **400** \| **FontWeight.Normal** |
| family | string \| [Resource](#resource) | No | Font family of the text. Use commas (,) to separate multiple fonts. The priority of the fonts is the sequence in which they are placed. An example value is **'Arial, HarmonyOS Sans'**. Currently, only the **'HarmonyOS Sans'** font is supported.| | family | string \| [Resource](#resource) | No | Font family of the text. Use commas (,) to separate multiple fonts. The priority of the fonts is the sequence in which they are placed. An example value is **'Arial, HarmonyOS Sans'**. The HarmonyOS Sans font and [register custom fonts](../apis/js-apis-font.md) are supported.|
| style | [FontStyle](ts-appendix-enums.md#fontstyle) | No | Font style.<br>Default value: **FontStyle.Normal** | | style | [FontStyle](ts-appendix-enums.md#fontstyle) | No | Font style.<br>Default value: **FontStyle.Normal** |
## Area<sup>8+</sup> ## Area<sup>8+</sup>
......
...@@ -16,14 +16,14 @@ You can draw an image around a component. ...@@ -16,14 +16,14 @@ You can draw an image around a component.
This API is supported in ArkTS widgets. This API is supported in ArkTS widgets.
| Name | Type | Description | | Name | Type | Description |
| ------ | ---------------------------------------- | ---------------------------------------- | | ------ | ------------------------------------------------------------ | ------------------------------------------------------------ |
| source | string \| [Resource](ts-types.md#resource) \| [linearGradient](ts-universal-attributes-gradient-color.md) | Source or gradient color of the border image.<br>**NOTE**<br>The border image source applies only to container components, such as **\<Row>**, **\<Column>**, and **\<Flex>**.| | source | string \| [Resource](ts-types.md#resource) \| [linearGradient](ts-universal-attributes-gradient-color.md) | Source or gradient color of the border image.<br>**NOTE**<br>The border image source applies only to container components, such as **\<Row>**, **\<Column>**, and **\<Flex>**.|
| slice | [Length](ts-types.md#length) \| [EdgeWidths](ts-types.md#edgewidths9) | Slice width of the border image.<br>Default value: **0** | | slice | [Length](ts-types.md#length) \| [EdgeWidths](ts-types.md#edgewidths9) | Slice width of the upper left corner, upper right corner, lower left corner, and lower right corner of the border image.<br>Default value: **0**<br>**NOTE**<br>If this parameter is set to a negative value, the default value is used.<br>When this parameter is set to a value of the [Length](ts-types.md#length) type, the value applies to the four corners in a unified manner.<br>When this parameter is set to a value of the [EdgeWidths](ts-types.md#edgewidths9) type:<br>- **Top**: slice height of the upper left or upper right corner of the image.<br>- **Bottom**: slice height of the lower left or lower right corner of the image.<br>- **Left**: slice width of the upper left or lower left corner of the image.<br>- **Right**: slice width of the upper right or lower right corner of the image.|
| width | [Length](ts-types.md#length) \| [EdgeWidths](ts-types.md#edgewidths9) | Width of the border image.<br>Default value: **0** | | width | [Length](ts-types.md#length) \| [EdgeWidths](ts-types.md#edgewidths9) | Width of the border image.<br>Default value: **0**<br>**NOTE**<br>If this parameter is set to a negative value, the default value is used.<br>When this parameter is set to a value of the [Length](ts-types.md#length) type, the value applies to the four corners in a unified manner.<br>When this parameter is set to a value of the [EdgeWidths](ts-types.md#edgewidths9) type:<br>- **Top**: width of the top edge of the border image.<br>- **Bottom**: width of the bottom edge of the border image.<br>- **Left**: width of the left edge of the border image.<br>- **Right**: width of the right edge of the border image.<br>If this parameter is set to a negative value, the value **1** is used.|
| outset | [Length](ts-types.md#length) \| [EdgeWidths](ts-types.md#edgewidths9) | Amount by which the border image is extended beyond the border box.<br>Default value: **0** | | outset | [Length](ts-types.md#length) \| [EdgeWidths](ts-types.md#edgewidths9) | Amount by which the border image is extended beyond the border box.<br>Default value: **0**<br>**NOTE**<br>If this parameter is set to a negative value, the default value is used.<br>When this parameter is set to a value of the [Length](ts-types.md#length) type, the value applies to the four corners in a unified manner.<br>When this parameter is set to a value of the [EdgeWidths](ts-types.md#edgewidths9) type:<br>- **Top**: amount by which the top edge of the border image is extended beyond the border box.<br>- **Bottom**: amount by which the bottom edge of the border image is extended beyond the border box.<br>- **Left**: amount by which the left edge of the border image is extended beyond the border box.<br>- **Right**: amount by which the right edge of the border image is extended beyond the border box.|
| repeat | [RepeatMode](#repeatmode) | Repeat mode of the border image.<br>Default value: **RepeatMode.Stretch** | | repeat | [RepeatMode](#repeatmode) | Repeat mode of the source image's slices on the border.<br>Default value: **RepeatMode.Stretch**|
| fill | boolean | Whether to fill the center of the border image.<br>Default value: **false** | | fill | boolean | Whether to fill the center of the border image.<br>Default value: **false** |
## RepeatMode ## RepeatMode
...@@ -32,9 +32,9 @@ This API is supported in ArkTS widgets. ...@@ -32,9 +32,9 @@ This API is supported in ArkTS widgets.
| Name | Description | | Name | Description |
| ------- | ----------------------------------- | | ------- | ----------------------------------- |
| Repeat | The source image's slices are tiled. Tiles beyond the border box will be clipped. | | Repeat | The source image's slices are tiled. Tiles beyond the border box will be clipped. |
| Stretch | The source image's slices stretched to fill the border box. | | Stretch | The source image's slices are stretched to fill the border box. |
| Round | The source image's slices are tiled to fill the border box. Tiles may be compressed when needed.| | Round | The source image's slices are tiled to fill the border box. Tiles may be compressed when needed.|
| Space | The source image's slices are tiled to fill the border box. Extra space will be filled in between tiles. | | Space | The source image's slices are tiled to fill the border box. Extra space will be distributed in between tiles. |
## Example ## Example
...@@ -77,35 +77,88 @@ struct Index { ...@@ -77,35 +77,88 @@ struct Index {
// xxx.ets // xxx.ets
@Entry @Entry
@Component @Component
struct Index { struct BorderImage {
@State outSetValue: number = 40 @State WidthValue: number = 0
@State SliceValue: number = 0
@State OutSetValue: number = 0
@State RepeatValue: RepeatMode[] = [RepeatMode.Repeat, RepeatMode.Stretch, RepeatMode.Round, RepeatMode.Space]
@State SelectIndex: number = 0
@State SelectText: string = 'Repeat'
@State FillValue: boolean = false
build() { build() {
Row() { Row() {
Column() { Column({ space: 20 }) {
Row() { Row() {
Text('This is borderImage.').textAlign(TextAlign.Center).fontSize(50) Text('This is borderImage.').textAlign(TextAlign.Center).fontSize(50)
} }
.borderImage({ .borderImage({
source: $r('app.media.icon'), source: $r('app.media.icon'),
slice: `${this.outSetValue}%`, slice: this.SliceValue,
width: `${this.outSetValue}px`, width: this.WidthValue,
outset: '5px', outset: this.OutSetValue,
repeat: RepeatMode.Repeat, repeat: this.RepeatValue[this.SelectIndex],
fill: false fill: this.FillValue
}) })
Slider({ Column() {
value: this.outSetValue, Text(`borderImageSlice = ${this.SliceValue}px`)
min: 0, Slider({
max: 100, value: this.SliceValue,
style: SliderStyle.OutSet min: 0,
}) max: 100,
.margin({ top: 30 }) style: SliderStyle.OutSet
.onChange((value: number, mode: SliderChangeMode) => { })
this.outSetValue = value .onChange((value: number, mode: SliderChangeMode) => {
console.info('value:' + value + 'mode:' + mode.toString()) this.SliceValue = value
})
}
Column() {
Text(`borderImageWidth = ${this.WidthValue}px`)
Slider({
value: this.WidthValue,
min: 0,
max: 100,
style: SliderStyle.OutSet
})
.onChange((value: number, mode: SliderChangeMode) => {
this.WidthValue = value
})
}
Column() {
Text(`borderImageOutSet = ${this.OutSetValue}px`)
Slider({
value: this.OutSetValue,
min: 0,
max: 100,
style: SliderStyle.OutSet
}) })
.onChange((value: number, mode: SliderChangeMode) => {
this.OutSetValue = value
})
}
Row() {
Text('borderImageRepeat: ')
Select([{ value: 'Repeat' }, { value: 'Stretch' }, { value: 'Round' }, { value: 'Space' }])
.value(this.SelectText)
.selected(this.SelectIndex)
.onSelect((index: number, text: string) => {
this.SelectIndex = index
this.SelectText = text
})
}
Row() {
Text(`borderImageFill: ${this.FillValue} `)
Toggle({ type: ToggleType.Switch, isOn: this.FillValue })
.onChange((isOn: boolean) => {
this.FillValue = isOn
})
}
} }
.width('100%') .width('100%')
} }
...@@ -114,4 +167,4 @@ struct Index { ...@@ -114,4 +167,4 @@ struct Index {
} }
``` ```
![zh-cn_image_borderImage](figures/borderImage.gif) ![borderImage](figures/borderImage.gif)
...@@ -17,8 +17,8 @@ Universal text attributes include text style attributes applicable to text conta ...@@ -17,8 +17,8 @@ Universal text attributes include text style attributes applicable to text conta
| fontSize | [Length](ts-types.md#length) | Font size. If the value is of the number type, the unit fp is used. The default font size is 16. This attribute cannot be set in percentage.<br>Since API version 9, this API is supported in ArkTS widgets.| | fontSize | [Length](ts-types.md#length) | Font size. If the value is of the number type, the unit fp is used. The default font size is 16. This attribute cannot be set in percentage.<br>Since API version 9, this API is supported in ArkTS widgets.|
| fontStyle | [FontStyle](ts-appendix-enums.md#fontstyle) | Font style.<br>Default value: **FontStyle.Normal**<br>Since API version 9, this API is supported in ArkTS widgets.| | fontStyle | [FontStyle](ts-appendix-enums.md#fontstyle) | Font style.<br>Default value: **FontStyle.Normal**<br>Since API version 9, this API is supported in ArkTS widgets.|
| fontWeight | number \| [FontWeight](ts-appendix-enums.md#fontweight) \| string | Font weight. For the number type, the value ranges from 100 to 900, at an interval of 100. The default value is **400**. A larger value indicates a larger font weight. The string type supports only the string of the number type, for example, **400**, **"bold"**, **"bolder"**, **"lighter"**, **"regular"**, and **"medium"**, which correspond to the enumerated values in **FontWeight**.<br>Default value: **FontWeight.Normal**<br>Since API version 9, this API is supported in ArkTS widgets.| | fontWeight | number \| [FontWeight](ts-appendix-enums.md#fontweight) \| string | Font weight. For the number type, the value ranges from 100 to 900, at an interval of 100. The default value is **400**. A larger value indicates a larger font weight. The string type supports only the string of the number type, for example, **400**, **"bold"**, **"bolder"**, **"lighter"**, **"regular"**, and **"medium"**, which correspond to the enumerated values in **FontWeight**.<br>Default value: **FontWeight.Normal**<br>Since API version 9, this API is supported in ArkTS widgets.|
| fontFamily | string \| [Resource](ts-types.md#resource) | Font family.<br> Default value: **'HarmonyOS Sans'**. Currently, only the default font is supported.<br>Since API version 9, this API is supported in ArkTS widgets.| | fontFamily | string \| [Resource](ts-types.md#resource) | Font family.<br>The HarmonyOS Sans font and [register custom fonts](../apis/js-apis-font.md) are supported.<br>Since API version 9, this API is supported in ArkTS widgets.|
| lineHeight | string \| number \| [Resource](ts-types.md#resource) | Text line height. If the value is less than or equal to **0**, the line height is not limited and the font size is adaptive. If the value of the number type, the unit fp is used.<br>Since API version 9, this API is supported in ArkTS widgets.| | lineHeight | string \| number \| [Resource](ts-types.md#resource) | Text line height. If the value is less than or equal to **0**, the line height is not limited and the font size is adaptive. If the value is of the number type, the unit fp is used.<br>Since API version 9, this API is supported in ArkTS widgets.|
| decoration | {<br>type: [TextDecorationType](ts-appendix-enums.md#textdecorationtype),<br>color?: [ResourceColor](ts-types.md#resourcecolor)<br>} | Style and color of the text decorative line.<br>Default value: {<br>type: TextDecorationType.None,<br>color: Color.Black<br>}<br>Since API version 9, this API is supported in ArkTS widgets.| | decoration | {<br>type: [TextDecorationType](ts-appendix-enums.md#textdecorationtype),<br>color?: [ResourceColor](ts-types.md#resourcecolor)<br>} | Style and color of the text decorative line.<br>Default value: {<br>type: TextDecorationType.None,<br>color: Color.Black<br>}<br>Since API version 9, this API is supported in ArkTS widgets.|
......
...@@ -532,7 +532,7 @@ When the size of the container in the flex layout is not large enough, the follo ...@@ -532,7 +532,7 @@ When the size of the container in the flex layout is not large enough, the follo
Text('flexBasis(100)') Text('flexBasis(100)')
.flexBasis(100) .flexBasis(100)
.width(200) // When width is set to 200 and flexBasis 100, the width is 100 vp, which means that the settings of flexBasis take precedence. .width(200) // When both width and flexBasis are set, flexBasis take precedence, and the width is 100 vp.
.height(100) .height(100)
.backgroundColor(0xD2B48C) .backgroundColor(0xD2B48C)
}.width('90%').height(120).padding(10).backgroundColor(0xAFEEEE) }.width('90%').height(120).padding(10).backgroundColor(0xAFEEEE)
...@@ -546,7 +546,7 @@ When the size of the container in the flex layout is not large enough, the follo ...@@ -546,7 +546,7 @@ When the size of the container in the flex layout is not large enough, the follo
```ts ```ts
Flex() { Flex() {
Text('flexGrow(1)') Text('flexGrow(1)')
.flexGrow(2) .flexGrow(1)
.width(100) .width(100)
.height(100) .height(100)
.backgroundColor(0xF5DEB3) .backgroundColor(0xF5DEB3)
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册