Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
OpenHarmony
Docs
提交
a57243b5
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看板
提交
a57243b5
编写于
8月 25, 2023
作者:
Y
yamila
提交者:
田雨
8月 28, 2023
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
fixed
27f24afc
from
https://gitee.com/yamila89/docs/pulls/23010
update promise Signed-off-by:
N
yamila
<
tianyu55@huawei.com
>
上级
36900347
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
206 addition
and
172 deletion
+206
-172
zh-cn/application-dev/reference/apis/js-apis-arkui-UIContext.md
...application-dev/reference/apis/js-apis-arkui-UIContext.md
+97
-81
zh-cn/application-dev/reference/apis/js-apis-router.md
zh-cn/application-dev/reference/apis/js-apis-router.md
+109
-91
未找到文件。
zh-cn/application-dev/reference/apis/js-apis-arkui-UIContext.md
浏览文件 @
a57243b5
...
...
@@ -721,19 +721,21 @@ pushUrl(options: router.RouterOptions): Promise<void>
```
ts
let
router
=
uiContext
.
getRouter
();
try
{
router
.
pushUrl
({
url
:
'
pages/routerpage2
'
,
params
:
{
data1
:
'
message
'
,
data2
:
{
data3
:
[
123
,
456
,
789
]
}
router
.
pushUrl
({
url
:
'
pages/routerpage2
'
,
params
:
{
data1
:
'
message
'
,
data2
:
{
data3
:
[
123
,
456
,
789
]
}
}
})
.
then
(()
=>
{
// success
})
.
catch
(
err
=>
{
console
.
error
(
`pushUrl failed, code is
${
err
.
code
}
, message is
${
err
.
message
}
`
);
})
}
catch
(
err
)
{
console
.
error
(
`pushUrl failed, code is
${
err
.
code
}
, message is
${
err
.
message
}
`
);
}
```
### pushUrl
...
...
@@ -817,19 +819,21 @@ pushUrl(options: router.RouterOptions, mode: router.RouterMode): Promise<void
```
ts
let
router
=
uiContext
.
getRouter
();
try
{
router
.
pushUrl
({
url
:
'
pages/routerpage2
'
,
params
:
{
data1
:
'
message
'
,
data2
:
{
data3
:
[
123
,
456
,
789
]
}
router
.
pushUrl
({
url
:
'
pages/routerpage2
'
,
params
:
{
data1
:
'
message
'
,
data2
:
{
data3
:
[
123
,
456
,
789
]
}
},
router
.
RouterMode
.
Standard
)
}
catch
(
err
)
{
console
.
error
(
`pushUrl failed, code is
${
err
.
code
}
, message is
${
err
.
message
}
`
);
}
}
},
router
.
RouterMode
.
Standard
)
.
then
(()
=>
{
// success
})
.
catch
(
err
=>
{
console
.
error
(
`pushUrl failed, code is
${
err
.
code
}
, message is
${
err
.
message
}
`
);
})
```
### pushUrl
...
...
@@ -912,16 +916,18 @@ replaceUrl(options: router.RouterOptions): Promise<void>
```
ts
let
router
=
uiContext
.
getRouter
();
try
{
router
.
replaceUrl
({
url
:
'
pages/detail
'
,
params
:
{
data1
:
'
message
'
}
router
.
replaceUrl
({
url
:
'
pages/detail
'
,
params
:
{
data1
:
'
message
'
}
})
.
then
(()
=>
{
// 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
...
...
@@ -1089,19 +1095,21 @@ pushNamedRoute(options: router.NamedRouterOptions): Promise<void>
```
ts
let
router
=
uiContext
.
getRouter
();
try
{
router
.
pushNamedRoute
({
name
:
'
myPage
'
,
params
:
{
data1
:
'
message
'
,
data2
:
{
data3
:
[
123
,
456
,
789
]
}
router
.
pushNamedRoute
({
name
:
'
myPage
'
,
params
:
{
data1
:
'
message
'
,
data2
:
{
data3
:
[
123
,
456
,
789
]
}
}
})
.
then
(()
=>
{
// success
})
.
catch
(
err
=>
{
console
.
error
(
`pushNamedRoute failed, code is
${
err
.
code
}
, message is
${
err
.
message
}
`
);
})
}
catch
(
err
)
{
console
.
error
(
`pushNamedRoute failed, code is
${
err
.
code
}
, message is
${
err
.
message
}
`
);
}
```
### pushNamedRoute
...
...
@@ -1184,19 +1192,21 @@ pushNamedRoute(options: router.NamedRouterOptions, mode: router.RouterMode): Pro
```
ts
let
router
=
uiContext
.
getRouter
();
try
{
router
.
pushNamedRoute
({
name
:
'
myPage
'
,
params
:
{
data1
:
'
message
'
,
data2
:
{
data3
:
[
123
,
456
,
789
]
}
router
.
pushNamedRoute
({
name
:
'
myPage
'
,
params
:
{
data1
:
'
message
'
,
data2
:
{
data3
:
[
123
,
456
,
789
]
}
},
router
.
RouterMode
.
Standard
)
}
catch
(
err
)
{
console
.
error
(
`pushNamedRoute failed, code is
${
err
.
code
}
, message is
${
err
.
message
}
`
);
}
}
},
router
.
RouterMode
.
Standard
)
.
then
(()
=>
{
// success
})
.
catch
(
err
=>
{
console
.
error
(
`pushNamedRoute failed, code is
${
err
.
code
}
, message is
${
err
.
message
}
`
);
})
```
### pushNamedRoute
...
...
@@ -1279,16 +1289,18 @@ replaceNamedRoute(options: router.NamedRouterOptions): Promise<void>
```
ts
let
router
=
uiContext
.
getRouter
();
try
{
router
.
replaceNamedRoute
({
name
:
'
myPage
'
,
params
:
{
data1
:
'
message
'
}
router
.
replaceNamedRoute
({
name
:
'
myPage
'
,
params
:
{
data1
:
'
message
'
}
})
.
then
(()
=>
{
// success
})
.
catch
(
err
=>
{
console
.
error
(
`replaceNamedRoute failed, code is
${
err
.
code
}
, message is
${
err
.
message
}
`
);
})
}
catch
(
err
)
{
console
.
error
(
`replaceNamedRoute failed, code is
${
err
.
code
}
, message is
${
err
.
message
}
`
);
}
```
### replaceNamedRoute
...
...
@@ -1368,16 +1380,18 @@ replaceNamedRoute(options: router.NamedRouterOptions, mode: router.RouterMode):
```
ts
let
router
=
uiContext
.
getRouter
();
try
{
router
.
replaceNamedRoute
({
name
:
'
myPage
'
,
params
:
{
data1
:
'
message
'
}
},
router
.
RouterMode
.
Standard
)
}
catch
(
err
)
{
console
.
error
(
`replaceNamedRoute failed, code is
${
err
.
code
}
, message is
${
err
.
message
}
`
);
}
router
.
replaceNamedRoute
({
name
:
'
myPage
'
,
params
:
{
data1
:
'
message
'
}
},
router
.
RouterMode
.
Standard
)
.
then
(()
=>
{
// success
})
.
catch
(
err
=>
{
console
.
error
(
`replaceNamedRoute failed, code is
${
err
.
code
}
, message is
${
err
.
message
}
`
);
})
```
### replaceNamedRoute
...
...
@@ -1531,13 +1545,15 @@ showAlertBeforeBackPage(options: router.EnableAlertOptions): void
```
ts
let
router
=
uiContext
.
getRouter
();
try
{
router
.
showAlertBeforeBackPage
({
message
:
'
Message Info
'
});
}
catch
(
error
)
{
console
.
error
(
`showAlertBeforeBackPage failed, code is
${
error
.
code
}
, message is
${
error
.
message
}
`
);
}
router
.
showAlertBeforeBackPage
({
message
:
'
Message Info
'
});
.
then
(()
=>
{
// success
})
.
catch
(
err
=>
{
console
.
error
(
`showAlertBeforeBackPage failed, code is
${
error
.
code
}
, message is
${
error
.
message
}
`
);
})
```
### hideAlertBeforeBackPage
...
...
zh-cn/application-dev/reference/apis/js-apis-router.md
浏览文件 @
a57243b5
...
...
@@ -51,19 +51,21 @@ pushUrl(options: RouterOptions): Promise<void>
**示例:**
```
ts
try
{
router
.
pushUrl
({
url
:
'
pages/routerpage2
'
,
params
:
{
data1
:
'
message
'
,
data2
:
{
data3
:
[
123
,
456
,
789
]
}
router
.
pushUrl
({
url
:
'
pages/routerpage2
'
,
params
:
{
data1
:
'
message
'
,
data2
:
{
data3
:
[
123
,
456
,
789
]
}
}
})
.
then
(()
=>
{
// success
})
.
catch
(
err
=>
{
console
.
error
(
`pushUrl failed, code is
${
err
.
code
}
, message is
${
err
.
message
}
`
);
})
}
catch
(
err
)
{
console
.
error
(
`pushUrl failed, code is
${
err
.
code
}
, message is
${
err
.
message
}
`
);
}
```
## router.pushUrl<sup>9+</sup>
...
...
@@ -144,19 +146,21 @@ pushUrl(options: RouterOptions, mode: RouterMode): Promise<void>
**示例:**
```
ts
try
{
router
.
pushUrl
({
url
:
'
pages/routerpage2
'
,
params
:
{
data1
:
'
message
'
,
data2
:
{
data3
:
[
123
,
456
,
789
]
}
router
.
pushUrl
({
url
:
'
pages/routerpage2
'
,
params
:
{
data1
:
'
message
'
,
data2
:
{
data3
:
[
123
,
456
,
789
]
}
},
router
.
RouterMode
.
Standard
)
}
catch
(
err
)
{
console
.
error
(
`pushUrl failed, code is
${
err
.
code
}
, message is
${
err
.
message
}
`
);
}
}
},
router
.
RouterMode
.
Standard
)
.
then
(()
=>
{
// success
})
.
catch
(
err
=>
{
console
.
error
(
`pushUrl failed, code is
${
err
.
code
}
, message is
${
err
.
message
}
`
);
})
```
## router.pushUrl<sup>9+</sup>
...
...
@@ -237,16 +241,18 @@ replaceUrl(options: RouterOptions): Promise<void>
**示例:**
```
ts
try
{
router
.
replaceUrl
({
url
:
'
pages/detail
'
,
params
:
{
data1
:
'
message
'
}
router
.
replaceUrl
({
url
:
'
pages/detail
'
,
params
:
{
data1
:
'
message
'
}
})
.
then
(()
=>
{
// 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
}
`
);
}
```
## router.replaceUrl<sup>9+</sup>
...
...
@@ -324,16 +330,18 @@ replaceUrl(options: RouterOptions, mode: RouterMode): Promise<void>
**示例:**
```
ts
try
{
router
.
replaceUrl
({
url
:
'
pages/detail
'
,
params
:
{
data1
:
'
message
'
}
},
router
.
RouterMode
.
Standard
)
}
catch
(
err
)
{
console
.
error
(
`replaceUrl failed, code is
${
err
.
code
}
, message is
${
err
.
message
}
`
);
}
router
.
replaceUrl
({
url
:
'
pages/detail
'
,
params
:
{
data1
:
'
message
'
}
},
router
.
RouterMode
.
Standard
)
.
then
(()
=>
{
// success
})
.
catch
(
err
=>
{
console
.
error
(
`replaceUrl failed, code is
${
err
.
code
}
, message is
${
err
.
message
}
`
);
})
```
## router.replaceUrl<sup>9+</sup>
...
...
@@ -412,19 +420,21 @@ pushNamedRoute(options: NamedRouterOptions): Promise<void>
**示例:**
```
ts
try
{
router
.
pushNamedRoute
({
name
:
'
myPage
'
,
params
:
{
data1
:
'
message
'
,
data2
:
{
data3
:
[
123
,
456
,
789
]
}
router
.
pushNamedRoute
({
name
:
'
myPage
'
,
params
:
{
data1
:
'
message
'
,
data2
:
{
data3
:
[
123
,
456
,
789
]
}
}
})
.
then
(()
=>
{
// success
})
.
catch
(
err
=>
{
console
.
error
(
`pushNamedRoute failed, code is
${
err
.
code
}
, message is
${
err
.
message
}
`
);
})
}
catch
(
err
)
{
console
.
error
(
`pushNamedRoute failed, code is
${
err
.
code
}
, message is
${
err
.
message
}
`
);
}
```
详细示例请参考:
[
UI开发-页面路由
](
../../ui/arkts-routing.md#命名路由
)
...
...
@@ -507,19 +517,21 @@ pushNamedRoute(options: NamedRouterOptions, mode: RouterMode): Promise<void&g
**示例:**
```
ts
try
{
router
.
pushNamedRoute
({
name
:
'
myPage
'
,
params
:
{
data1
:
'
message
'
,
data2
:
{
data3
:
[
123
,
456
,
789
]
}
router
.
pushNamedRoute
({
name
:
'
myPage
'
,
params
:
{
data1
:
'
message
'
,
data2
:
{
data3
:
[
123
,
456
,
789
]
}
},
router
.
RouterMode
.
Standard
)
}
catch
(
err
)
{
console
.
error
(
`pushNamedRoute failed, code is
${
err
.
code
}
, message is
${
err
.
message
}
`
);
}
}
},
router
.
RouterMode
.
Standard
)
.
then
(()
=>
{
// success
})
.
catch
(
err
=>
{
console
.
error
(
`pushNamedRoute failed, code is
${
err
.
code
}
, message is
${
err
.
message
}
`
);
})
```
## router.pushNamedRoute<sup>10+</sup>
...
...
@@ -600,16 +612,18 @@ replaceNamedRoute(options: NamedRouterOptions): Promise<void>
**示例:**
```
ts
try
{
router
.
replaceNamedRoute
({
name
:
'
myPage
'
,
params
:
{
data1
:
'
message
'
}
router
.
replaceNamedRoute
({
name
:
'
myPage
'
,
params
:
{
data1
:
'
message
'
}
})
.
then
(()
=>
{
// success
})
.
catch
(
err
=>
{
console
.
error
(
`replaceNamedRoute failed, code is
${
err
.
code
}
, message is
${
err
.
message
}
`
);
})
}
catch
(
err
)
{
console
.
error
(
`replaceNamedRoute failed, code is
${
err
.
code
}
, message is
${
err
.
message
}
`
);
}
```
## router.replaceNamedRoute<sup>10+</sup>
...
...
@@ -687,16 +701,18 @@ replaceNamedRoute(options: NamedRouterOptions, mode: RouterMode): Promise<voi
**示例:**
```
ts
try
{
router
.
replaceNamedRoute
({
name
:
'
myPage
'
,
params
:
{
data1
:
'
message
'
}
},
router
.
RouterMode
.
Standard
)
}
catch
(
err
)
{
console
.
error
(
`replaceNamedRoute failed, code is
${
err
.
code
}
, message is
${
err
.
message
}
`
);
}
router
.
replaceNamedRoute
({
name
:
'
myPage
'
,
params
:
{
data1
:
'
message
'
}
},
router
.
RouterMode
.
Standard
)
.
then
(()
=>
{
// success
})
.
catch
(
err
=>
{
console
.
error
(
`replaceNamedRoute failed, code is
${
err
.
code
}
, message is
${
err
.
message
}
`
);
})
```
## router.replaceNamedRoute<sup>10+</sup>
...
...
@@ -857,13 +873,15 @@ showAlertBeforeBackPage(options: EnableAlertOptions): void
**示例:**
```
ts
try
{
router
.
showAlertBeforeBackPage
({
message
:
'
Message Info
'
});
}
catch
(
error
)
{
console
.
error
(
`showAlertBeforeBackPage failed, code is
${
error
.
code
}
, message is
${
error
.
message
}
`
);
}
router
.
showAlertBeforeBackPage
({
message
:
'
Message Info
'
})
.
then
(()
=>
{
// success
})
.
catch
(
err
=>
{
console
.
error
(
`showAlertBeforeBackPage failed, code is
${
error
.
code
}
, message is
${
error
.
message
}
`
);
})
```
## EnableAlertOptions
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录