> The initial APIs of this module are supported since API version 8. Newly added APIs will be marked with a superscript to indicate their earliest API version.
| duration | number | No| Duration that the toast will remain on the screen. The default value is 1500 ms. The recommended value range is 1500 ms to 10000 ms. If a value less than 1500 ms is set, the default value is used.|
| bottom | <length> | No| Distance between the toast frame and the bottom of the screen. This parameter is available only on phones and tablets.|
| callback | AsyncCallback<[ShowDialogSuccessResponse](#showdialogsuccessresponse)> | Yes| Callback used to return the dialog box response result.|
| title | string | No| Title of the text to display.|
| message | string | No| Text body.|
| buttons | Array | No| Array of buttons in the dialog box. The array structure is **{text:'button', color: '\#666666'}**. One to three buttons are supported. The first button is of the **positiveButton** type, the second is of the **negativeButton** type, and the third is of the **neutralButton** type.|
| options | [ActionMenuOptions](#actionmenuoptions) | Yes| Action menu options.|
| callback | AsyncCallback<[ActionMenuSuccessResponse](#actionmenusuccessresponse)> | Yes| Callback used to return the action menu response result.|
| title | string | No| Title of the text to display.|
| buttons | Array | Yes| Array of menu items. The array structure is **{text:'button', color: '\#666666'}**. One to six items are supported. If there are more than six items, extra items will not be displayed.|
> - The initial APIs of this module are supported since API version 8. Newly added APIs will be marked with a superscript to indicate their earliest API version.
> - Page routing APIs can be invoked only after page rendering is complete. Do not call the APIs in **onInit** and **onReady** when the page is still in the rendering phase.
| options | [RouterOptions](#routeroptions) | Yes| 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 this parameter is not set, the application returns to the previous page.|
**Example**
```
// index page
export default {
indexPushPage() {
router.push({
url: 'pages/detail/detail',
});
}
}
```
```
// detail page
export default {
detailPushPage() {
router.push({
url: 'pages/mall/mall',
});
}
}
```
```
// Navigate from the mall page to the detail page through router.back().
export default {
mallBackPage() {
router.back();
}
}
```
```
// Navigate from the detail page to the index page through router.back().
export default {
defaultBack() {
router.back();
}
}
```
```
// Return to the detail page through router.back().
export default {
backToDetail() {
router.back({uri:'pages/detail/detail'});
}
}
```
## router.clear
clear(): void
Clears all historical pages in the stack and retains only the current page at the top of the stack.
| index | number | Index of the current page in the stack.<br>> ![icon-note.gif](public_sys-resources/icon-note.gif) **NOTE**<br>> The index starts from 1 from the bottom to the top of the stack.|
| name | string | Name of the current page, that is, the file name.|
| url | string | Yes| URI of the destination page, in either of the following formats:<br>- Absolute path of the page. The value is available in the pages list in the config.json file, for example:<br> - pages/index/index<br> - pages/detail/detail<br>- Particular path. If the URI is a slash (/), the home page is displayed.|
| params | Object | No| Data that needs to be passed to the destination page during redirection. After the destination page is displayed, it can use the passed data, for example, **this.data1** (**data1** is a key in **params**). If there is the same key (for example, **data1**) on the destination page, the passed **data1** value will replace the original value on the destination page.|
> - The APIs of this module are no longer maintained since API version 8. You are advised to use ['@ohos.prompt](js-apis-prompt.md)' instead.
>
>
> - The initial APIs of this module are supported since API version 3. Newly added APIs will be marked with a superscript to indicate their earliest API version.
| duration | number | No | Duration that the toast will remain on the screen. The default value is 1500 ms. The recommended value range is 1500 ms to 10000 ms. If a value less than 1500 ms is set, the default value is used.|
| bottom<sup>5+</sup> | string\|number | No | Distance between the toast frame and the bottom of the screen. This parameter is available only on phones and tablets. |
| title | string | No | Title of the text to display. |
| message | string | No | Text body. |
| buttons | [[Button](#button), [Button](#button)?, [Button](#button)?] | No | Array of buttons in the dialog box. The array structure is **{text:'button', color: '\#666666'}**. One to six buttons are supported. If there are more than six buttons, extra buttons will not be displayed.|
| success | (data: [ShowDialogSuccessResponse](#showdialogsuccessresponse)) => void | No | Callback upon success. |
| cancel | (data: string, code: string) => void | No | Callback upon failure. |
| complete | (data: string) => void | No | Called when the API call is complete. |
## ShowActionMenuOptions<sup>6+</sup>
Describes the options for showing the action menu.
| title | string | No | Title of the text to display. |
| buttons | [[Button](#button), [Button](#button)?, [Button](#button)?, [Button](#button)?, [Button](#button)?, [Button](#button)?] | Yes | Array of buttons in the dialog box. The array structure is **{text:'button', color: '\#666666'}**. One to six buttons are supported.|
| success | (tapIndex: number, errMsg: string) => void | No | Invoked when a dialog box is displayed. |
| fail | (errMsg: string) => void | No | Callback upon failure. |
| complete | (data: string) => void | No | Invoked when a dialog box is closed. |
> - The initial APIs of this module are supported since API version 3. Newly added APIs will be marked with a superscript to indicate their earliest API version.
>
> - The APIs of this module are no longer maintained since API version 8. You are advised to use ['@ohos.router'](js-apis-router.md) instead.
> - The APIs of this module are no longer maintained since API version 8. You are advised to use ['@ohos.router'](js-apis-router.md) instead.
>
>
> - The initial APIs of this module are supported since API version 3. Newly added APIs will be marked with a superscript to indicate their earliest API version.
## Modules to Import
## Modules to Import
...
@@ -22,9 +25,9 @@ Navigates to a specified page in the application.
...
@@ -22,9 +25,9 @@ Navigates to a specified page in the application.
| uri | string | Yes| URI of the destination page, in either of the following formats:<br>1. Absolute path, which is provided by the **pages** list in the **config.json** file. Example:<br>- pages/index/index<br> -pages/detail/detail<br>2. Specific path. If the URI is a slash (/), the home page is displayed.|
| uri | string | Yes | URI of the destination page, in either of the following formats:<br>1. Absolute path, which is provided by the **pages** list in the **config.json** file. Example:<br>- pages/index/index<br> -pages/detail/detail<br>2. Specific path. If the URI is a slash (/), the home page is displayed.|
| params | Object | No| Data that needs to be passed to the destination page during redirection. After the destination page is displayed, it can use the passed data, for example, **this.data1** (**data1** is a key in **params**). If there is the same key (for example, **data1**) on the destination page, the passed **data1** value will replace the original value on the destination page.|
| params | Object | No| Data that needs to be passed to the destination page during redirection. After the destination page is displayed, it can use the passed data, for example, **this.data1** (**data1** is a key in **params**). If there is the same key (for example, **data1**) on the destination page, the passed **data1** value will replace the original value on the destination page.|
## BackRouterOptions
## BackRouterOptions
...
@@ -346,10 +349,10 @@ Defines the parameters for routing back.
...
@@ -346,10 +349,10 @@ Defines the parameters for routing back.
**System capability**: The items in the table below require different system capabilities. For details, see the table.
**System capability**: The items in the table below require different system capabilities. For details, see the table.
| uri | string | No| URI of the page to return to. If the specified page does not exist in the page stack, the application does not respond. If this parameter is not set, the application returns to the previous page.<br>**System capability**: SystemCapability.ArkUI.ArkUI.Full|
| uri | string | No | URI of the page to return to. If the specified page does not exist in the page stack, the application does not respond. If this parameter is not set, the application returns to the previous page.<br>**System capability**: SystemCapability.ArkUI.ArkUI.Full|
| params | Object | No| Data that needs to be passed to the destination page during redirection.<br>**System capability**: SystemCapability.ArkUI.ArkUI.Lite|
| params | Object | No| Data that needs to be passed to the destination page during redirection.<br>**System capability**: SystemCapability.ArkUI.ArkUI.Lite|