Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
OpenHarmony
Docs
提交
665bcc00
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看板
提交
665bcc00
编写于
9月 05, 2023
作者:
L
lixia
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
windowExtensionContext.md指南ts示例代码arkts 告警修复
Signed-off-by:
N
lixia
<
lixia110@huawei.com
>
上级
b7b6fe61
变更
1
隐藏空白更改
内联
并排
Showing
1 changed file
with
68 addition
and
50 deletion
+68
-50
zh-cn/application-dev/reference/apis/js-apis-inner-application-windowExtensionContext.md
.../apis/js-apis-inner-application-windowExtensionContext.md
+68
-50
未找到文件。
zh-cn/application-dev/reference/apis/js-apis-inner-application-windowExtensionContext.md
浏览文件 @
665bcc00
...
@@ -17,14 +17,16 @@ WindowExtensionContext模块提供[WindowExtensionAbility](js-apis-application-w
...
@@ -17,14 +17,16 @@ WindowExtensionContext模块提供[WindowExtensionAbility](js-apis-application-w
在使用WindowExtensionContext的功能前,需要通过WindowExtensionAbility子类实例获取。
在使用WindowExtensionContext的功能前,需要通过WindowExtensionAbility子类实例获取。
```
ts
```
ts
import
WindowExtensionAbility
from
'
@ohos.application.WindowExtensionAbility
'
;
import
WindowExtensionAbility
from
'
@ohos.application.WindowExtensionAbility
'
;
import
WindowExtensionContext
from
'
application/WindowExtensionContext
'
;
let
context
;
let
context
:
WindowExtensionContext
|
null
=
null
;
class
WindowExtAbility
extends
WindowExtensionAbility
{
onConnect
()
{
class
WindowExtAbility
extends
WindowExtensionAbility
{
context
=
this
.
context
;
// 获取WindowExtensionContext
onConnect
()
{
}
context
=
this
.
context
;
// 获取WindowExtensionContext
}
}
}
```
```
## WindowExtensionContext.startAbility
## WindowExtensionContext.startAbility
...
@@ -46,28 +48,36 @@ startAbility(want: Want, options: StartOptions, callback: AsyncCallback<void&
...
@@ -46,28 +48,36 @@ startAbility(want: Want, options: StartOptions, callback: AsyncCallback<void&
**示例:**
**示例:**
```
ts
```
ts
var
want
=
{
import
{
BusinessError
}
from
'
@ohos.base
'
;
bundleName
:
'
com.example.myapplication
'
,
import
Want
from
'
@ohos.app.ability.Want
'
;
abilityName
:
'
MainAbility
'
import
StartOptions
from
'
@ohos.app.ability.StartOptions
'
;
};
var
options
=
{
let
want
:
Want
=
{
windowMode
:
102
bundleName
:
'
com.example.myapplication
'
,
};
abilityName
:
'
MainAbility
'
};
try
{
let
options
:
StartOptions
=
{
this
.
context
.
startAbility
(
want
,
options
,
(
error
)
=>
{
windowMode
:
102
if
(
error
.
code
)
{
};
// 处理业务逻辑错误
console
.
error
(
'
startAbility failed, error.code: ${error.code}, error.message: ${error.message}
'
);
try
{
return
;
this
.
context
.
startAbility
(
want
,
options
,
(
error
:
BusinessError
)
=>
{
}
let
message
=
(
error
as
BusinessError
).
message
;
// 执行正常业务
let
errCode
=
(
error
as
BusinessError
).
code
;
console
.
log
(
'
startAbility succeed
'
);
if
(
errCode
)
{
});
// 处理业务逻辑错误
}
catch
(
paramError
)
{
console
.
error
(
'
startAbility failed, error.code: ${errCode}, error.message: ${message}
'
);
// 处理入参错误异常
return
;
console
.
error
(
'
error.code: ${paramError.code}, error.message: ${paramError.message}
'
);
}
}
// 执行正常业务
console
.
log
(
'
startAbility succeed
'
);
});
}
catch
(
paramError
)
{
// 处理入参错误异常
let
message
=
(
paramError
as
BusinessError
).
message
;
let
errCode
=
(
paramError
as
BusinessError
).
code
;
console
.
error
(
'
error.code: ${errCode}, error.message: ${message}
'
);
}
```
```
## WindowExtensionContext.startAbility
## WindowExtensionContext.startAbility
...
@@ -94,26 +104,34 @@ startAbility(want: Want, options?: StartOptions): Promise\<void>
...
@@ -94,26 +104,34 @@ startAbility(want: Want, options?: StartOptions): Promise\<void>
**示例:**
**示例:**
```
ts
```
ts
var
want
=
{
import
{
BusinessError
}
from
'
@ohos.base
'
;
bundleName
:
'
com.example.myapp
'
,
import
Want
from
'
@ohos.app.ability.Want
'
;
abilityName
:
'
MainAbility
'
import
StartOptions
from
'
@ohos.app.ability.StartOptions
'
;
};
var
options
=
{
let
want
:
Want
=
{
windowMode
:
102
,
bundleName
:
'
com.example.myapp
'
,
};
abilityName
:
'
MainAbility
'
};
try
{
let
options
:
StartOptions
=
{
this
.
context
.
startAbility
(
want
,
options
)
windowMode
:
102
,
.
then
((
data
)
=>
{
};
// 执行正常业务
console
.
log
(
'
startAbility succeed
'
);
try
{
})
this
.
context
.
startAbility
(
want
,
options
)
.
catch
((
error
)
=>
{
.
then
(()
=>
{
// 处理业务逻辑错误
// 执行正常业务
console
.
error
(
'
startAbility failed, error.code: ${error.code}, error.message: ${error.message}
'
);
console
.
log
(
'
startAbility succeed
'
);
});
})
}
catch
(
paramError
)
{
.
catch
((
error
:
BusinessError
)
=>
{
// 处理入参错误异常
// 处理业务逻辑错误
console
.
error
(
'
error.code: ${paramError.code}, error.message: ${paramError.message}
'
);
let
message
=
(
error
as
BusinessError
).
message
;
}
let
errCode
=
(
error
as
BusinessError
).
code
;
console
.
error
(
'
startAbility failed, error.code: ${errCode}, error.message: ${message}
'
);
});
}
catch
(
paramError
)
{
// 处理入参错误异常
let
message
=
(
paramError
as
BusinessError
).
message
;
let
errCode
=
(
paramError
as
BusinessError
).
code
;
console
.
error
(
'
error.code: ${errCode}, error.message: ${message}
'
);
}
```
```
\ No newline at end of file
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录