Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
OpenHarmony
Docs
提交
4fc21964
D
Docs
项目概览
OpenHarmony
/
Docs
大约 1 年 前同步成功
通知
159
Star
292
Fork
28
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
D
Docs
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
未验证
提交
4fc21964
编写于
3月 23, 2022
作者:
L
LiAn
提交者:
Gitee
3月 23, 2022
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
update zh-cn/application-dev/reference/apis/js-apis-system-router.md.
Signed-off-by:
N
LiAn
<
lian15@huawei.com
>
上级
ae39eb4e
变更
1
显示空白变更内容
内联
并排
Showing
1 changed file
with
93 addition
and
25 deletion
+93
-25
zh-cn/application-dev/reference/apis/js-apis-system-router.md
...n/application-dev/reference/apis/js-apis-system-router.md
+93
-25
未找到文件。
zh-cn/application-dev/reference/apis/js-apis-system-router.md
浏览文件 @
4fc21964
...
...
@@ -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/>
-
页面绝对路径,由配置文件中pages列表提供,例如:
<br/>
-
pages/index/index
<br/>
-
pages/detail/detail
<br/>
-
特殊值,如果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/>
-
页面绝对路径,由配置文件中pages列表提供,例如:
<br/>
-
pages/index/index
<br/>
-
pages/detail/detail
<br/>
-
特殊值,如果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():
<
RouterState
>
getState():
RouterState
获取当前页面的状态信息。
**系统能力:**
SystemCapability.ArkUI.ArkUI.Full
**返回值:**
**表1**
RouterState
| 参数名 | 类型 | 说明 |
| -------- | -------- | -------- |
| index | number | 表示当前页面在页面栈中的索引。
<br/>
>
![icon-note.gif](public_sys-resources/icon-note.gif)
**说明:**
<br/>
>
从栈底到栈顶,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 | ()
=
>
void | 否 | 接口调用成功的回调函数。 |
| fail | ()
=
>
void | 否 | 接口调用失败的回调函数。 |
| complete | ()
=
>
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 | ()
=
>
void | 否 | 接口调用成功的回调函数。 |
| fail | ()
=
>
void | 否 | 接口调用失败的回调函数。 |
| complete | ()
=
>
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.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录