提交 b49d559d 编写于 作者: W wusongqing

updated docs

Signed-off-by: Nwusongqing <wusongqing@huawei.com>
上级 e122fa58
# Page Routing # Page Routing
> ![icon-note.gif](public_sys-resources/icon-note.gif) **NOTE** > ![icon-note.gif](public_sys-resources/icon-note.gif) **NOTE**<br/>
> >
> - 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. > - 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. > - 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.
...@@ -24,13 +24,13 @@ Navigates to a specified page in the application. ...@@ -24,13 +24,13 @@ Navigates to a specified page in the application.
**System capability**: SystemCapability.ArkUI.ArkUI.Full **System capability**: SystemCapability.ArkUI.ArkUI.Full
**Parameters** **Parameters**
| Name| Type| Mandatory| Description| | Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- | | -------- | -------- | -------- | -------- |
| options | [RouterOptions](#routeroptions) | Yes| Page routing parameters.| | options | [RouterOptions](#routeroptions) | Yes| Page routing parameters.|
**Example** **Example**
``` ```js
// Current page // Current page
export default { export default {
pushPage() { pushPage() {
...@@ -46,7 +46,7 @@ Navigates to a specified page in the application. ...@@ -46,7 +46,7 @@ Navigates to a specified page in the application.
} }
} }
``` ```
``` ```js
// routerpage2 page // routerpage2 page
export default { export default {
data: { data: {
...@@ -72,12 +72,13 @@ Replaces the current page with another one in the application and destroys the c ...@@ -72,12 +72,13 @@ Replaces the current page with another one in the application and destroys the c
**System capability**: SystemCapability.ArkUI.ArkUI.Full **System capability**: SystemCapability.ArkUI.ArkUI.Full
**Parameters** **Parameters**
| Name| Type| Mandatory| Description| | Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- | | -------- | -------- | -------- | -------- |
| options | [RouterOptions](#routeroptions) | Yes| Description of the new page.| | options | [RouterOptions](#routeroptions) | Yes| Description of the new page.|
**Example** **Example**
```
```js
// Current page // Current page
export default { export default {
replacePage() { replacePage() {
...@@ -91,7 +92,7 @@ Replaces the current page with another one in the application and destroys the c ...@@ -91,7 +92,7 @@ Replaces the current page with another one in the application and destroys the c
} }
``` ```
``` ```js
// detail page // detail page
export default { export default {
data: { data: {
...@@ -112,12 +113,12 @@ Returns to the previous page or a specified page. ...@@ -112,12 +113,12 @@ Returns to the previous page or a specified page.
**System capability**: SystemCapability.ArkUI.ArkUI.Full **System capability**: SystemCapability.ArkUI.ArkUI.Full
**Parameters** **Parameters**
| Name| Type| Mandatory| Description| | Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- | | -------- | -------- | -------- | -------- |
| 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.| | 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** **Example**
``` ```js
// index page // index page
export default { export default {
indexPushPage() { indexPushPage() {
...@@ -128,7 +129,7 @@ Returns to the previous page or a specified page. ...@@ -128,7 +129,7 @@ Returns to the previous page or a specified page.
} }
``` ```
``` ```js
// detail page // detail page
export default { export default {
detailPushPage() { detailPushPage() {
...@@ -139,7 +140,7 @@ Returns to the previous page or a specified page. ...@@ -139,7 +140,7 @@ Returns to the previous page or a specified page.
} }
``` ```
``` ```js
// Navigate from the mall page to the detail page through router.back(). // Navigate from the mall page to the detail page through router.back().
export default { export default {
mallBackPage() { mallBackPage() {
...@@ -148,7 +149,7 @@ Returns to the previous page or a specified page. ...@@ -148,7 +149,7 @@ Returns to the previous page or a specified page.
} }
``` ```
``` ```js
// Navigate from the detail page to the index page through router.back(). // Navigate from the detail page to the index page through router.back().
export default { export default {
defaultBack() { defaultBack() {
...@@ -157,7 +158,7 @@ Returns to the previous page or a specified page. ...@@ -157,7 +158,7 @@ Returns to the previous page or a specified page.
} }
``` ```
``` ```js
// Return to the detail page through router.back(). // Return to the detail page through router.back().
export default { export default {
backToDetail() { backToDetail() {
...@@ -175,12 +176,12 @@ Clears all historical pages in the stack and retains only the current page at th ...@@ -175,12 +176,12 @@ Clears all historical pages in the stack and retains only the current page at th
**System capability**: SystemCapability.ArkUI.ArkUI.Full **System capability**: SystemCapability.ArkUI.ArkUI.Full
**Example** **Example**
``` ```js
export default { export default {
clearPage() { clearPage() {
router.clear(); router.clear();
} }
} }js
``` ```
## router.getLength ## router.getLength
...@@ -190,12 +191,12 @@ getLength(): string ...@@ -190,12 +191,12 @@ getLength(): string
Obtains the number of pages in the current stack. Obtains the number of pages in the current stack.
**Return value** **Return value**
| Type| Description| | Type| Description|
| -------- | -------- | | -------- | -------- |
| string | Number of pages in the stack. The maximum value is **32**.| | string | Number of pages in the stack. The maximum value is **32**.|
**Example** **Example**
``` ```js
export default { export default {
getLength() { getLength() {
var size = router.getLength(); var size = router.getLength();
...@@ -222,14 +223,14 @@ Describes the page routing state. ...@@ -222,14 +223,14 @@ Describes the page routing state.
**System capability**: SystemCapability.ArkUI.ArkUI.Full **System capability**: SystemCapability.ArkUI.ArkUI.Full
| Name| Type| Description| | Name| Type| Description|
| -------- | -------- | -------- | | -------- | -------- | -------- |
| index | number | Index of the current page in the stack.<br>>&nbsp;![icon-note.gif](public_sys-resources/icon-note.gif)&nbsp;**NOTE**<br>>&nbsp;The index starts from 1 from the bottom to the top of the stack.| | index | number | Index of the current page in the stack.<br>>&nbsp;![icon-note.gif](public_sys-resources/icon-note.gif)&nbsp;**NOTE**<br>>&nbsp;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.| | name | string | Name of the current page, that is, the file name.|
| path | string | Path of the current page.| | path | string | Path of the current page.|
**Example** **Example**
``` ```js
export default { export default {
getState() { getState() {
var page = router.getState(); var page = router.getState();
...@@ -249,13 +250,13 @@ Enables the display of a confirm dialog box before returning to the previous pag ...@@ -249,13 +250,13 @@ Enables the display of a confirm dialog box before returning to the previous pag
**System capability**: SystemCapability.ArkUI.ArkUI.Full **System capability**: SystemCapability.ArkUI.ArkUI.Full
**Parameters** **Parameters**
| Name| Type| Mandatory| Description| | Name| Type| Mandatory| Description|
| -------- | -------- | -------- | -------- | | -------- | -------- | -------- | -------- |
| options | [EnableAlertOptions](#enablealertoptions) | Yes| Description of the dialog box.| | options | [EnableAlertOptions](#enablealertoptions) | Yes| Description of the dialog box.|
**Example** **Example**
``` ```js
export default { export default {
enableAlertBeforeBackPage() { enableAlertBeforeBackPage() {
router.enableAlertBeforeBackPage({ router.enableAlertBeforeBackPage({
...@@ -289,7 +290,7 @@ Disables the display of a confirm dialog box before returning to the previous pa ...@@ -289,7 +290,7 @@ Disables the display of a confirm dialog box before returning to the previous pa
**System capability**: SystemCapability.ArkUI.ArkUI.Full **System capability**: SystemCapability.ArkUI.ArkUI.Full
**Example** **Example**
``` ```js
export default { export default {
disableAlertBeforeBackPage() { disableAlertBeforeBackPage() {
router.disableAlertBeforeBackPage(); router.disableAlertBeforeBackPage();
...@@ -314,7 +315,7 @@ Obtains the parameters passed from the page that initiates redirection to the cu ...@@ -314,7 +315,7 @@ Obtains the parameters passed from the page that initiates redirection to the cu
**Example** **Example**
- Web-like example - Web-like example
``` ```js
// Current page // Current page
export default { export default {
pushPage() { pushPage() {
...@@ -327,7 +328,7 @@ Obtains the parameters passed from the page that initiates redirection to the cu ...@@ -327,7 +328,7 @@ Obtains the parameters passed from the page that initiates redirection to the cu
} }
} }
``` ```
``` ```js
// detail page // detail page
export default { export default {
onInit() { onInit() {
...@@ -338,7 +339,7 @@ Obtains the parameters passed from the page that initiates redirection to the cu ...@@ -338,7 +339,7 @@ Obtains the parameters passed from the page that initiates redirection to the cu
- Declarative example - Declarative example
``` ```ts
// Navigate to the target page through router.push with the params parameter carried. // Navigate to the target page through router.push with the params parameter carried.
import router from '@ohos.router' import router from '@ohos.router'
...@@ -384,7 +385,7 @@ Obtains the parameters passed from the page that initiates redirection to the cu ...@@ -384,7 +385,7 @@ Obtains the parameters passed from the page that initiates redirection to the cu
} }
``` ```
``` ```ts
// Receive the transferred parameters on the second page. // Receive the transferred parameters on the second page.
import router from '@ohos.router' import router from '@ohos.router'
...@@ -392,8 +393,8 @@ Obtains the parameters passed from the page that initiates redirection to the cu ...@@ -392,8 +393,8 @@ Obtains the parameters passed from the page that initiates redirection to the cu
@Component @Component
struct Second { struct Second {
private content: string = "This is the second page." private content: string = "This is the second page."
@State text: string = router.getParams().text @State text: string = router.getParams()['text']
@State data: any = router.getParams().data @State data: any = router.getParams()['data']
@State secondData : string = '' @State secondData : string = ''
build() { build() {
......
# Application Context # Application Context
> ![icon-note.gif](public_sys-resources/icon-note.gif) **NOTE** > ![icon-note.gif](public_sys-resources/icon-note.gif) **NOTE**<br/>
> - The APIs of this module are no longer maintained since API version 7. You are advised to use the new APIs. > - The APIs of this module are no longer maintained since API version 7. You are advised to use the new APIs.
> >
> - 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 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.
...@@ -138,7 +138,8 @@ Sets the maximum size (in bytes) of the image data cached in the memory before d ...@@ -138,7 +138,8 @@ Sets the maximum size (in bytes) of the image data cached in the memory before d
export default { export default {
onCreate() { onCreate() {
app.setImageRawDataCacheSize(100) // Set the upper limit of the memory for caching image data before decoding to 100 MB. app.setImageRawDataCacheSize(104857600)
// Set the upper limit of the memory for caching image data before decoding to 100 MB. (100 x 1024 x 1024 B =104857600 B = 100 MB).
console.info('Application onCreate') console.info('Application onCreate')
}, },
onDestroy() { onDestroy() {
...@@ -168,7 +169,8 @@ Sets the maximum size of the image file cache (in bytes) to speed up the loading ...@@ -168,7 +169,8 @@ Sets the maximum size of the image file cache (in bytes) to speed up the loading
export default { export default {
onCreate() { onCreate() {
app.setImageFileCacheSize(200) // Set the upper limit of the image file cache to 200 MB. app.setImageFileCacheSize(209715200)
// Set the upper limit of the image file cache to 200 MB. (200 x 1024 x 1024 B= 209715200 B = 200 MB).
console.info('Application onCreate') console.info('Application onCreate')
}, },
onDestroy() { onDestroy() {
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册