未验证 提交 4fc21964 编写于 作者: L LiAn 提交者: Gitee

update zh-cn/application-dev/reference/apis/js-apis-system-router.md.

Signed-off-by: NLiAn <lian15@huawei.com>
上级 ae39eb4e
......@@ -13,7 +13,7 @@ import router from '@system.router';
## router.push
push(Object): void
push(options: RouterOptions): void
跳转到应用内的指定页面。
......@@ -23,8 +23,7 @@ push(Object): void
| 参数名 | 类型 | 必填 | 说明 |
| -------- | -------- | -------- | -------- |
| uri | string | 是 | 表示目标页面的uri,可以用以下两种格式:<br/>-&nbsp;页面绝对路径,由配置文件中pages列表提供,例如:<br/>&nbsp;&nbsp;-&nbsp;pages/index/index<br/>&nbsp;&nbsp;-&nbsp;pages/detail/detail<br/>-&nbsp;特殊值,如果uri的值是"/",则跳转到首页。 |
| params | Object | 否 | 跳转时要同时传递到目标页面的数据,跳转到目标页面后,参数可以在页面中直接使用,如this.data1(data1为跳转时params参数中的key值)。如果目标页面中已有该字段,则其值会被传入的字段值覆盖。 |
| options | [RouterOptions](#routeroptions) | 是 | 页面路由参数,详细请参考RouterOptions。|
**示例:**
......@@ -68,7 +67,7 @@ export default {
## router.replace
replace(Object): void
replace(options: RouterOptions): void
用应用内的某个页面替换当前页面,并销毁被替换的页面。
......@@ -78,8 +77,7 @@ replace(Object): void
| 参数名 | 类型 | 必填 | 说明 |
| -------- | -------- | -------- | -------- |
| uri | string | 是 | 目标页面的uri,可以是以下的两种格式:<br/>-&nbsp;页面绝对路径,由配置文件中pages列表提供,例如:<br/>&nbsp;&nbsp;-&nbsp;pages/index/index<br/>&nbsp;&nbsp;-&nbsp;pages/detail/detail<br/>-&nbsp;特殊值,如果uri的值是"/",则跳转到首页。 |
| params | Object | 否 | 跳转时要同时传递到目标页面的数据,跳转到目标页面后,参数可以在页面中直接使用,如this.data1(data1为跳转时params参数中的key值)。如果目标页面中已有该字段,则其值会被传入的字段值覆盖。 |
| options | [RouterOptions](#routeroptions) | 是 | 页面路由参数,详细请参考RouterOptions。|
**示例:**
......@@ -112,7 +110,7 @@ export default {
## router.back
back(Object): void
back(options?: BackRouterOptions): void
返回上一页面或指定的页面。
......@@ -122,8 +120,7 @@ back(Object): void
| 参数名 | 类型 | 必填 | 说明 |
| -------- | -------- | -------- | -------- |
| uri | string | 否 | 返回到指定uri的界面,如果页面栈上没有uri页面,则不响应该情况。如果uri未设置,则返回上一页。 |
| params | Object | 否 | 跳转时要同时传递到目标页面的数据 |
| options | [BackRouterOptions](#backrouteroptions) | 是 | 详细请参考BackRouterOptions。|
**示例:**
......@@ -183,6 +180,20 @@ export default {
> ![icon-note.gif](public_sys-resources/icon-note.gif) **说明:**
> 示例中的uri字段是页面路由,由配置文件中的pages列表指定。
## router.getParams
getParams(): ParamsInterface
获取当前页面的参数信息。
**系统能力:** SystemCapability.ArkUI.ArkUI.Full
**返回值:**
| 类型 | 说明 |
| -------- | -------- |
| [ParamsInterface](#paramsinterface) | 详细请参见ParamsInterface。|
## router.clear
clear(): void
......@@ -228,20 +239,17 @@ export default {
## router.getState
getState(): &lt;RouterState&gt;
getState(): RouterState
获取当前页面的状态信息。
**系统能力:** SystemCapability.ArkUI.ArkUI.Full
**返回值:**
**表1** RouterState
| 参数名 | 类型 | 说明 |
| -------- | -------- | -------- |
| index | number | 表示当前页面在页面栈中的索引。<br/>>&nbsp;![icon-note.gif](public_sys-resources/icon-note.gif)&nbsp;**说明:**<br/>>&nbsp;从栈底到栈顶,index从1开始递增。 |
| name | string | 表示当前页面的名称,即对应文件名。 |
| path | string | 表示当前页面的路径。 |
| 参数类型 | 说明 |
| -------- | -------- |
| [RouterState](#routerstate) | 详细请参见RouterState。|
**示例:**
......@@ -258,7 +266,7 @@ export default {
## router.enableAlertBeforeBackPage<sup>6+</sup>
enableAlertBeforeBackPage(Object): void
enableAlertBeforeBackPage(options: EnableAlertBeforeBackPageOptions): void
开启页面返回询问对话框。
......@@ -268,10 +276,7 @@ enableAlertBeforeBackPage(Object): void
| 参数名 | 类型 | 必填 | 说明 |
| -------- | -------- | -------- | -------- |
| message | string | 是 | 询问对话框内容。 |
| success | ()&nbsp;=&gt;&nbsp;void | 否 | 接口调用成功的回调函数。 |
| fail | ()&nbsp;=&gt;&nbsp;void | 否 | 接口调用失败的回调函数。 |
| complete | ()&nbsp;=&gt;&nbsp;void | 否 | 接口调用结束的回调函数。 |
| options | [EnableAlertBeforeBackPageOptions](#EnableAlertbeforebackpageoptions) | 是 | 详细请参见EnableAlertBeforeBackPageOptions。 |
**示例:**
......@@ -293,7 +298,7 @@ export default {
## router.disableAlertBeforeBackPage<sup>6+</sup>
disableAlertBeforeBackPage(Object): void
disableAlertBeforeBackPage(options?: DisableAlertBeforeBackPageOptions): void
禁用页面返回询问对话框。
......@@ -303,9 +308,7 @@ disableAlertBeforeBackPage(Object): void
| 参数名 | 类型 | 必填 | 说明 |
| -------- | -------- | -------- | -------- |
| success | ()&nbsp;=&gt;&nbsp;void | 否 | 接口调用成功的回调函数。 |
| fail | ()&nbsp;=&gt;&nbsp;void | 否 | 接口调用失败的回调函数。 |
| complete | ()&nbsp;=&gt;&nbsp;void | 否 | 接口调用结束的回调函数。 |
| options | [DisableAlertBeforeBackPageOptions](#disablealertbeforebackpageoptions)| 否 | 详细请参见DisableAlertBeforeBackPageOptions。 |
**示例:**
......@@ -324,3 +327,68 @@ export default {
}
```
## RouterOptions
定义路由器的选项。
**系统能力:** 以下各项对应的系统能力均为SystemCapability.ArkUI.ArkUI.Lite
| 名称 | 参数类型 | 必填 | 说明 |
| -------- | -------- | -------- | -------- |
| uri | string | 是 | 目标页面的uri,可以是以下的两种格式:<br/>1. 页面的绝对路径,由config.json文件中的页面列表提供。例如:<br/>- pages/index/index<br/> -pages/detail/detail<br/>2. 特定路径。如果URI为斜杠(/),则显示主页。 |
| params | Object | 否 | 跳转时要同时传递到目标页面的数据,跳转到目标页面后,参数可以在页面中直接使用,如this.data1(data1为跳转时params参数中的key值)。如果目标页面中已有该字段,则其值会被传入的字段值覆盖。 |
## BackRouterOptions
定义路由器返回的选项。
**系统能力:** 以下各项对应的系统能力有所不同,详见下表。
| 名称 | 参数类型 | 必填 | 说明 |
| -------- | -------- | -------- | -------- |
| uri | string | 否 | 返回到指定uri的界面,如果页面栈上没有uri页面,则不响应该情况。如果uri未设置,则返回上一页。 <br>**系统能力:** SystemCapability.ArkUI.ArkUI.Full|
| params | Object | 否 | 跳转时要同时传递到目标页面的数据。 <br>**系统能力:** SystemCapability.ArkUI.ArkUI.Lite|
## RouterState
定义路由器的状态。
**系统能力:** 以下各项对应的系统能力均为SystemCapability.ArkUI.ArkUI.Full
| 名称 | 参数类型 | 必填 | 说明 |
| -------- | -------- | -------- |-------- |
| index | number | 是 | 表示当前页面在页面栈中的索引。从栈底到栈顶,index从1开始递增。 |
| name | string | 是 | 表示当前页面的名称,即对应文件名。 |
| path | string | 是 | 表示当前页面的路径。 |
## EnableAlertBeforeBackPageOptions<sup>6+</sup>
定义EnableAlertBe beforeBackPage选项。
**系统能力:** 以下各项对应的系统能力均为SystemCapability.ArkUI.ArkUI.Full
| 名称 | 参数类型 | 必填 | 说明 |
| -------- | -------- | -------- | -------- |
| message | string | 是 | 询问对话框内容。 |
| success | (errMsg: string) => void | 否 | 弹出对话框时调用,errMsg表示返回信息。 |
| fail | (errMsg: string) => void | 否 | 接口调用失败的回调函数,errMsg表示返回信息。 |
| complete | () => void | 否 | 接口调用结束的回调函数。 |
## DisableAlertBeforeBackPageOptions<sup>6+</sup>
定义DisableAlertBeforeBackPage参数选项。
**系统能力:** 以下各项对应的系统能力均为SystemCapability.ArkUI.ArkUI.Full
| 名称 | 参数类型 | 必填 | 说明 |
| -------- | -------- | -------- | -------- |
| success | (errMsg: string) => void | 否 | 弹出对话框时调用,errMsg表示返回信息。 |
| fail | (errMsg: string) => void | 否 | 接口调用失败的回调函数,errMsg表示返回信息。|
| complete | () => void | 否 | 接口调用结束的回调函数。 |
## ParamsInterface
| 名称 | 参数类型 | 说明 |
| -------- | -------- | -------- |
| [key: string] | Object| 路由参数列表。 |
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册