Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
OpenHarmony
Docs
提交
7d07bb0f
D
Docs
项目概览
OpenHarmony
/
Docs
大约 2 年 前同步成功
通知
161
Star
293
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看板
未验证
提交
7d07bb0f
编写于
1月 04, 2023
作者:
O
openharmony_ci
提交者:
Gitee
1月 04, 2023
浏览文件
操作
浏览文件
下载
差异文件
!12925 卡片API参考文档优化
Merge pull request !12925 from yangzk/master
上级
be87c2e7
56ec85ec
变更
6
隐藏空白更改
内联
并排
Showing
6 changed file
with
512 addition
and
401 deletion
+512
-401
zh-cn/application-dev/reference/apis/js-apis-app-form-formBindingData.md
...on-dev/reference/apis/js-apis-app-form-formBindingData.md
+10
-13
zh-cn/application-dev/reference/apis/js-apis-app-form-formExtensionAbility.md
...v/reference/apis/js-apis-app-form-formExtensionAbility.md
+59
-31
zh-cn/application-dev/reference/apis/js-apis-app-form-formHost.md
...plication-dev/reference/apis/js-apis-app-form-formHost.md
+249
-197
zh-cn/application-dev/reference/apis/js-apis-app-form-formInfo.md
...plication-dev/reference/apis/js-apis-app-form-formInfo.md
+7
-7
zh-cn/application-dev/reference/apis/js-apis-app-form-formProvider.md
...ation-dev/reference/apis/js-apis-app-form-formProvider.md
+127
-106
zh-cn/application-dev/reference/apis/js-apis-inner-application-formExtensionContext.md
...ce/apis/js-apis-inner-application-formExtensionContext.md
+60
-47
未找到文件。
zh-cn/application-dev/reference/apis/js-apis-app-form-formBindingData.md
浏览文件 @
7d07bb0f
...
...
@@ -48,20 +48,17 @@ createFormBindingData(obj?: Object | string): FormBindingData
**示例:**
```
ts
import
featureAbility
from
'
@ohos.ability.featureAbility
'
;
import
fileio
from
'
@ohos.fileio
'
;
let
context
=
featureAbility
.
getContext
();
context
.
getOrCreateLocalDir
((
err
,
data
)
=>
{
let
path
=
data
+
"
/xxx.jpg
"
;
let
fd
=
fileio
.
openSync
(
path
);
import
fs
from
'
@ohos.file.fs
'
;
import
formBindingData
from
'
@ohos.app.form.formBindingData
'
;
try
{
let
fd
=
fs
.
openSync
(
'
/path/to/form.png
'
)
let
obj
=
{
"
temperature
"
:
"
21°
"
,
"
formImages
"
:
{
"
image
"
:
fd
}
"
formImages
"
:
{
"
image
"
:
fd
}
};
try
{
formBindingData
.
createFormBindingData
(
obj
);
}
catch
(
error
)
{
console
.
log
(
`catch err->
${
JSON
.
stringify
(
err
)}
`
);
}
})
formBindingData
.
createFormBindingData
(
obj
);
}
catch
(
error
)
{
console
.
log
(
`catch error, code:
${
error
.
code
}
, message:
${
error
.
message
}
)`
);
}
```
\ No newline at end of file
zh-cn/application-dev/reference/apis/js-apis-app-form-formExtensionAbility.md
浏览文件 @
7d07bb0f
...
...
@@ -33,7 +33,7 @@ onAddForm(want: Want): formBindingData.FormBindingData
| 参数名 | 类型 | 必填 | 说明 |
| ------ | -------------------------------------- | ---- | ------------------------------------------------------------ |
| want |
[
Want
](
js-apis-application-want.md
)
| 是 | 当前
ExtensionAbility
相关的Want类型信息,包括卡片ID、卡片名称、卡片样式等。这些卡片信息必须作为持久数据进行管理,以便后续更新和删除卡片。 |
| want |
[
Want
](
js-apis-application-want.md
)
| 是 | 当前
卡片
相关的Want类型信息,包括卡片ID、卡片名称、卡片样式等。这些卡片信息必须作为持久数据进行管理,以便后续更新和删除卡片。 |
**返回值:**
...
...
@@ -45,17 +45,19 @@ onAddForm(want: Want): formBindingData.FormBindingData
```
ts
import
FormExtensionAbility
from
'
@ohos.app.form.FormExtensionAbility
'
;
import
formBindingData
from
'
@ohos.app.form.formBindingData
'
;
export
default
class
MyFormExtensionAbility
extends
FormExtensionAbility
{
onAddForm
(
want
)
{
console
.
log
(
'
FormExtensionAbility onAddForm, want:
'
+
want
.
abilityName
);
let
dataObj1
=
{
temperature
:
"
11c
"
,
"
time
"
:
"
11:00
"
temperature
:
"
11c
"
,
"
time
"
:
"
11:00
"
};
let
obj1
=
formBindingData
.
createFormBindingData
(
dataObj1
);
return
obj1
;
}
}
}
;
```
## onCastToNormalForm
...
...
@@ -75,11 +77,13 @@ onCastToNormalForm(formId: string): void
**示例:**
```
ts
import
FormExtensionAbility
from
'
@ohos.app.form.FormExtensionAbility
'
;
export
default
class
MyFormExtensionAbility
extends
FormExtensionAbility
{
onCastToNormalForm
(
formId
)
{
console
.
log
(
'
FormExtensionAbility onCastToNormalForm, formId:
'
+
formId
);
}
}
}
;
```
## onUpdateForm
...
...
@@ -99,17 +103,24 @@ onUpdateForm(formId: string): void
**示例:**
```
ts
import
formBindingData
from
'
@ohos.app.form.formBindingData
'
import
FormExtensionAbility
from
'
@ohos.app.form.FormExtensionAbility
'
;
import
formBindingData
from
'
@ohos.app.form.formBindingData
'
;
import
formProvider
from
'
@ohos.app.form.formProvider
'
;
export
default
class
MyFormExtensionAbility
extends
FormExtensionAbility
{
onUpdateForm
(
formId
)
{
console
.
log
(
'
FormExtensionAbility onUpdateForm, formId:
'
+
formId
);
let
obj2
=
formBindingData
.
createFormBindingData
({
temperature
:
"
22c
"
,
time
:
"
22:00
"
});
this
.
context
.
updateForm
(
formId
,
obj2
).
then
((
data
)
=>
{
let
obj2
=
formBindingData
.
createFormBindingData
({
temperature
:
"
22c
"
,
time
:
"
22:00
"
});
formProvider
.
updateForm
(
formId
,
obj2
).
then
((
data
)
=>
{
console
.
log
(
'
FormExtensionAbility context updateForm, data:
'
+
data
);
}).
catch
((
error
)
=>
{
console
.
error
(
'
Operation updateForm failed. Cause:
'
+
error
);});
}
}
console
.
error
(
'
Operation updateForm failed. Cause:
'
+
error
);
});
}
};
```
## onChangeFormVisibility
...
...
@@ -129,21 +140,28 @@ onChangeFormVisibility(newStatus: { [key: string]: number }): void
**示例:**
```
ts
import
FormExtensionAbility
from
'
@ohos.app.form.FormExtensionAbility
'
;
import
formBindingData
from
'
@ohos.app.form.formBindingData
'
import
formProvider
from
'
@ohos.app.form.formProvider
'
;
export
default
class
MyFormExtensionAbility
extends
FormExtensionAbility
{
onChangeFormVisibility
(
newStatus
)
{
console
.
log
(
'
FormExtensionAbility onChangeFormVisibility, newStatus:
'
+
newStatus
);
let
obj2
=
formBindingData
.
createFormBindingData
({
temperature
:
"
22c
"
,
time
:
"
22:00
"
});
for
(
let
key
in
newStatus
)
{
console
.
log
(
'
FormExtensionAbility onChangeFormVisibility, key:
'
+
key
+
"
, value=
"
+
newStatus
[
key
]);
this
.
context
.
updateForm
(
key
,
obj2
).
then
((
data
)
=>
{
console
.
log
(
'
FormExtensionAbility onChangeFormVisibility, newStatus:
'
+
newStatus
);
let
obj2
=
formBindingData
.
createFormBindingData
({
temperature
:
"
22c
"
,
time
:
"
22:00
"
});
for
(
let
key
in
newStatus
)
{
console
.
log
(
'
FormExtensionAbility onChangeFormVisibility, key:
'
+
key
+
"
, value=
"
+
newStatus
[
key
]);
formProvider
.
updateForm
(
key
,
obj2
).
then
((
data
)
=>
{
console
.
log
(
'
FormExtensionAbility context updateForm, data:
'
+
data
);
}).
catch
((
error
)
=>
{
console
.
error
(
'
Operation updateForm failed. Cause:
'
+
error
);});
}).
catch
((
error
)
=>
{
console
.
error
(
'
Operation updateForm failed. Cause:
'
+
error
);
});
}
}
}
}
;
```
## onFormEvent
...
...
@@ -164,11 +182,13 @@ onFormEvent(formId: string, message: string): void
**示例:**
```
ts
export
default
class
MyFormExtension
extends
FormExtensionAbility
{
import
FormExtensionAbility
from
'
@ohos.app.form.FormExtensionAbility
'
;
export
default
class
MyFormExtensionAbility
extends
FormExtensionAbility
{
onFormEvent
(
formId
,
message
)
{
console
.
log
(
'
FormExtensionAbility onFormEvent, formId:
'
+
formId
+
"
, message:
"
+
message
);
}
}
}
;
```
## onRemoveForm
...
...
@@ -188,11 +208,13 @@ onRemoveForm(formId: string): void
**示例:**
```
ts
import
FormExtensionAbility
from
'
@ohos.app.form.FormExtensionAbility
'
;
export
default
class
MyFormExtensionAbility
extends
FormExtensionAbility
{
onRemoveForm
(
formId
)
{
console
.
log
(
'
FormExtensionAbility onRemoveForm, formId:
'
+
formId
);
}
}
}
;
```
## onConfigurationUpdate
...
...
@@ -212,11 +234,13 @@ onConfigurationUpdate(newConfig: Configuration): void;
**示例:**
```
ts
class
MyFormExtensionAbility
extends
FormExtensionAbility
{
import
FormExtensionAbility
from
'
@ohos.app.form.FormExtensionAbility
'
;
export
default
class
MyFormExtensionAbility
extends
FormExtensionAbility
{
onConfigurationUpdate
(
config
)
{
console
.
log
(
'
onConfigurationUpdate, config:
'
+
JSON
.
stringify
(
config
));
}
}
}
;
```
## onAcquireFormState
...
...
@@ -236,13 +260,15 @@ onAcquireFormState?(want: Want): formInfo.FormState;
**示例:**
```
ts
import
FormExtensionAbility
from
'
@ohos.app.form.FormExtensionAbility
'
;
import
formInfo
from
'
@ohos.app.form.formInfo
'
;
class
MyFormExtensionAbility
extends
FormExtensionAbility
{
export
default
class
MyFormExtensionAbility
extends
FormExtensionAbility
{
onAcquireFormState
(
want
)
{
console
.
log
(
'
FormExtensionAbility onAcquireFormState, want:
'
+
want
);
return
formInfo
.
FormState
.
UNKNOWN
;
}
}
}
;
```
## onShareForm
...
...
@@ -270,14 +296,16 @@ onShareForm?(formId: string): { [key: string]: any }
**示例:**
```
ts
class
MyFormExtensionAbility
extends
FormExtensionAbility
{
import
FormExtensionAbility
from
'
@ohos.app.form.FormExtensionAbility
'
;
export
default
class
MyFormExtensionAbility
extends
FormExtensionAbility
{
onShareForm
(
formId
)
{
console
.
log
(
'
FormExtensionAbility onShareForm, formId:
'
+
formId
);
let
wantParams
=
{
"
temperature
"
:
"
20
"
,
"
time
"
:
"
2022-8-8 09:59
"
,
"
temperature
"
:
"
20
"
,
"
time
"
:
"
2022-8-8 09:59
"
,
};
return
wantParams
;
}
}
}
;
```
\ No newline at end of file
zh-cn/application-dev/reference/apis/js-apis-app-form-formHost.md
浏览文件 @
7d07bb0f
# @ohos.app.form.formHost (
F
ormHost)
# @ohos.app.form.formHost (
f
ormHost)
F
ormHost模块提供了卡片使用方相关接口的能力,包括对使用方同一用户下安装的卡片进行删除、释放、请求更新、获取卡片信息、状态等操作。
f
ormHost模块提供了卡片使用方相关接口的能力,包括对使用方同一用户下安装的卡片进行删除、释放、请求更新、获取卡片信息、状态等操作。
> **说明:**
>
...
...
@@ -34,25 +34,24 @@ deleteForm(formId: string, callback: AsyncCallback<void>): void
| 错误码ID | 错误信息 |
| -------- | -------- |
| 401 |
If the input parameter is not valid parameter.
|
以上错误码的详细介绍请参见
[
卡片错误码
](
../errorcodes/errorcode-form.md
)
。
| 401 |
调用接口入参错误。
|
|以上错误码的详细介绍请参见
[
卡片错误码
](
../errorcodes/errorcode-form.md
)
。||
**示例:**
```
ts
try
{
var
formId
=
"
12400633174999288
"
;
formHost
.
deleteForm
(
formId
,
(
error
,
data
)
=>
{
let
formId
=
"
12400633174999288
"
;
formHost
.
deleteForm
(
formId
,
(
error
)
=>
{
if
(
error
)
{
console
.
log
(
'
formHost deleteForm, error:
'
+
JSON
.
stringify
(
error
)
);
console
.
log
(
`error, code:
${
error
.
code
}
, message:
${
error
.
message
}
)`
);
}
else
{
console
.
log
(
'
formHost deleteForm success
'
);
}
});
}
catch
(
error
)
{
console
.
log
(
`catch err
->
${
JSON
.
stringify
(
error
)}
`
);
console
.
log
(
`catch err
or, code:
${
error
.
code
}
, message:
${
error
.
message
}
)
`
);
}
```
## deleteForm
...
...
@@ -82,21 +81,21 @@ deleteForm(formId: string): Promise<void>
| 错误码ID | 错误信息 |
| -------- | -------- |
| 401 |
If the input parameter is not valid parameter.
|
以上错误码的详细介绍请参见
[
卡片错误码
](
../errorcodes/errorcode-form.md
)
。
| 401 |
调用接口入参错误。
|
|以上错误码的详细介绍请参见
[
卡片错误码
](
../errorcodes/errorcode-form.md
)
。||
**参数:**
```
ts
try
{
var
formId
=
"
12400633174999288
"
;
let
formId
=
"
12400633174999288
"
;
formHost
.
deleteForm
(
formId
).
then
(()
=>
{
console
.
log
(
'
formHost deleteForm success
'
);
}).
catch
((
error
)
=>
{
console
.
log
(
'
formHost deleteForm, error:
'
+
JSON
.
stringify
(
error
)
);
console
.
log
(
`error, code:
${
error
.
code
}
, message:
${
error
.
message
}
)`
);
});
}
catch
(
error
)
{
console
.
log
(
`catch err
->
${
JSON
.
stringify
(
error
)}
`
);
console
.
log
(
`catch err
or, code:
${
error
.
code
}
, message:
${
error
.
message
}
)
`
);
}
```
...
...
@@ -121,21 +120,21 @@ releaseForm(formId: string, callback: AsyncCallback<void>): void
| 错误码ID | 错误信息 |
| -------- | -------- |
| 401 |
If the input parameter is not valid parameter.
|
以上错误码的详细介绍请参见
[
卡片错误码
](
../errorcodes/errorcode-form.md
)
。
| 401 |
调用接口入参错误。
|
|以上错误码的详细介绍请参见
[
卡片错误码
](
../errorcodes/errorcode-form.md
)
。||
**示例:**
```
ts
try
{
var
formId
=
"
12400633174999288
"
;
formHost
.
releaseForm
(
formId
,
(
error
,
data
)
=>
{
let
formId
=
"
12400633174999288
"
;
formHost
.
releaseForm
(
formId
,
(
error
)
=>
{
if
(
error
)
{
console
.
log
(
'
formHost releaseForm, error:
'
+
JSON
.
stringify
(
error
)
);
console
.
log
(
`error, code:
${
error
.
code
}
, message:
${
error
.
message
}
)`
);
}
});
}
catch
(
error
)
{
console
.
log
(
`catch err
->
${
JSON
.
stringify
(
error
)}
`
);
console
.
log
(
`catch err
or, code:
${
error
.
code
}
, message:
${
error
.
message
}
)
`
);
}
```
...
...
@@ -161,21 +160,21 @@ releaseForm(formId: string, isReleaseCache: boolean, callback: AsyncCallback<
| 错误码ID | 错误信息 |
| -------- | -------- |
| 401 |
If the input parameter is not valid parameter.
|
以上错误码的详细介绍请参见
[
卡片错误码
](
../errorcodes/errorcode-form.md
)
。
| 401 |
调用接口入参错误。
|
|以上错误码的详细介绍请参见
[
卡片错误码
](
../errorcodes/errorcode-form.md
)
。||
**示例:**
```
ts
try
{
var
formId
=
"
12400633174999288
"
;
formHost
.
releaseForm
(
formId
,
true
,
(
error
,
data
)
=>
{
let
formId
=
"
12400633174999288
"
;
formHost
.
releaseForm
(
formId
,
true
,
(
error
)
=>
{
if
(
error
)
{
console
.
log
(
'
formHost releaseForm, error:
'
+
JSON
.
stringify
(
error
)
);
console
.
log
(
`error, code:
${
error
.
code
}
, message:
${
error
.
message
}
)`
);
}
});
}
catch
(
error
)
{
console
.
log
(
`catch err
->
${
JSON
.
stringify
(
error
)}
`
);
console
.
log
(
`catch err
or, code:
${
error
.
code
}
, message:
${
error
.
message
}
)
`
);
}
```
...
...
@@ -206,21 +205,21 @@ releaseForm(formId: string, isReleaseCache?: boolean): Promise<void>
| 错误码ID | 错误信息 |
| -------- | -------- |
| 401 |
If the input parameter is not valid parameter.
|
以上错误码的详细介绍请参见
[
卡片错误码
](
../errorcodes/errorcode-form.md
)
。
| 401 |
调用接口入参错误。
|
|以上错误码的详细介绍请参见
[
卡片错误码
](
../errorcodes/errorcode-form.md
)
。||
**示例:**
```
ts
try
{
var
formId
=
"
12400633174999288
"
;
let
formId
=
"
12400633174999288
"
;
formHost
.
releaseForm
(
formId
,
true
).
then
(()
=>
{
console
.
log
(
'
formHost releaseForm success
'
);
}).
catch
((
error
)
=>
{
console
.
log
(
'
formHost releaseForm, error:
'
+
JSON
.
stringify
(
error
)
);
console
.
log
(
`error, code:
${
error
.
code
}
, message:
${
error
.
message
}
)`
);
});
}
catch
(
error
)
{
console
.
log
(
`catch err
->
${
JSON
.
stringify
(
error
)}
`
);
console
.
log
(
`catch err
or, code:
${
error
.
code
}
, message:
${
error
.
message
}
)
`
);
}
```
...
...
@@ -245,21 +244,21 @@ requestForm(formId: string, callback: AsyncCallback<void>): void
| 错误码ID | 错误信息 |
| -------- | -------- |
| 401 |
If the input parameter is not valid parameter.
|
以上错误码的详细介绍请参见
[
卡片错误码
](
../errorcodes/errorcode-form.md
)
。
| 401 |
调用接口入参错误。
|
|以上错误码的详细介绍请参见
[
卡片错误码
](
../errorcodes/errorcode-form.md
)
。||
**示例:**
```
ts
try
{
var
formId
=
"
12400633174999288
"
;
formHost
.
requestForm
(
formId
,
(
error
,
data
)
=>
{
let
formId
=
"
12400633174999288
"
;
formHost
.
requestForm
(
formId
,
(
error
)
=>
{
if
(
error
)
{
console
.
log
(
'
formHost requestForm, error:
'
+
JSON
.
stringify
(
error
)
);
console
.
log
(
`error, code:
${
error
.
code
}
, message:
${
error
.
message
}
)`
);
}
});
}
catch
(
error
)
{
console
.
log
(
`catch err
->
${
JSON
.
stringify
(
error
)}
`
);
console
.
log
(
`catch err
or, code:
${
error
.
code
}
, message:
${
error
.
message
}
)
`
);
}
```
...
...
@@ -289,21 +288,21 @@ requestForm(formId: string): Promise<void>
| 错误码ID | 错误信息 |
| -------- | -------- |
| 401 |
If the input parameter is not valid parameter.
|
以上错误码的详细介绍请参见
[
卡片错误码
](
../errorcodes/errorcode-form.md
)
。
| 401 |
调用接口入参错误。
|
|以上错误码的详细介绍请参见
[
卡片错误码
](
../errorcodes/errorcode-form.md
)
。||
**示例:**
```
ts
try
{
var
formId
=
"
12400633174999288
"
;
let
formId
=
"
12400633174999288
"
;
formHost
.
requestForm
(
formId
).
then
(()
=>
{
console
.
log
(
'
formHost requestForm success
'
);
}).
catch
((
error
)
=>
{
console
.
log
(
'
formHost requestForm, error:
'
+
JSON
.
stringify
(
error
)
);
console
.
log
(
`error, code:
${
error
.
code
}
, message:
${
error
.
message
}
)`
);
});
}
catch
(
error
)
{
console
.
log
(
`catch err
->
${
JSON
.
stringify
(
error
)}
`
);
console
.
log
(
`catch err
or, code:
${
error
.
code
}
, message:
${
error
.
message
}
)
`
);
}
```
...
...
@@ -323,27 +322,27 @@ castToNormalForm(formId: string, callback: AsyncCallback<void>): void
| 参数名 | 类型 | 必填 | 说明 |
| ------ | ------ | ---- | ------- |
| formId | string | 是 | 卡片标识。 |
| callback | AsyncCallback
<
void
>
| 是 | 回调函数。当将指定的临时卡片转换为普通卡片成功,err为undefined,否则为错误对象。 |
| callback | AsyncCallback
<
void
>
| 是 | 回调函数。当将指定的临时卡片转换为普通卡片成功,err
or
为undefined,否则为错误对象。 |
**错误码:**
| 错误码ID | 错误信息 |
| -------- | -------- |
| 401 |
If the input parameter is not valid parameter.
|
以上错误码的详细介绍请参见
[
卡片错误码
](
../errorcodes/errorcode-form.md
)
。
| 401 |
调用接口入参错误。
|
|以上错误码的详细介绍请参见
[
卡片错误码
](
../errorcodes/errorcode-form.md
)
。||
**示例:**
```
ts
try
{
var
formId
=
"
12400633174999288
"
;
formHost
.
castToNormalForm
(
formId
,
(
error
,
data
)
=>
{
let
formId
=
"
12400633174999288
"
;
formHost
.
castToNormalForm
(
formId
,
(
error
)
=>
{
if
(
error
)
{
console
.
log
(
'
formHost castTempForm, error:
'
+
JSON
.
stringify
(
error
)
);
console
.
log
(
`error, code:
${
error
.
code
}
, message:
${
error
.
message
}
)`
);
}
});
}
catch
(
error
)
{
console
.
log
(
`catch err
->
${
JSON
.
stringify
(
error
)}
`
);
console
.
log
(
`catch err
or, code:
${
error
.
code
}
, message:
${
error
.
message
}
)
`
);
}
```
...
...
@@ -373,21 +372,21 @@ castToNormalForm(formId: string): Promise<void>
| 错误码ID | 错误信息 |
| -------- | -------- |
| 401 |
If the input parameter is not valid parameter.
|
以上错误码的详细介绍请参见
[
卡片错误码
](
../errorcodes/errorcode-form.md
)
。
| 401 |
调用接口入参错误。
|
|以上错误码的详细介绍请参见
[
卡片错误码
](
../errorcodes/errorcode-form.md
)
。||
**示例:**
```
ts
try
{
var
formId
=
"
12400633174999288
"
;
let
formId
=
"
12400633174999288
"
;
formHost
.
castToNormalForm
(
formId
).
then
(()
=>
{
console
.
log
(
'
formHost castTempForm success
'
);
}).
catch
((
error
)
=>
{
console
.
log
(
'
formHost castTempForm, error:
'
+
JSON
.
stringify
(
error
)
);
console
.
log
(
`error, code:
${
error
.
code
}
, message:
${
error
.
message
}
)`
);
});
}
catch
(
error
)
{
console
.
log
(
`catch err
->
${
JSON
.
stringify
(
error
)}
`
);
console
.
log
(
`catch err
or, code:
${
error
.
code
}
, message:
${
error
.
message
}
)
`
);
}
```
...
...
@@ -406,27 +405,27 @@ notifyVisibleForms(formIds: Array<string>, callback: AsyncCallback<void
| 参数名 | 类型 | 必填 | 说明 |
| ------ | ------ | ---- | ------- |
| formIds | Array
<
string
>
| 是 | 卡片标识列表。 |
| callback | AsyncCallback
<
void
>
| 是 | 回调函数。当向卡片框架发送通知以使指定的卡片可见成功,err为undefined,否则为错误对象。 |
| callback | AsyncCallback
<
void
>
| 是 | 回调函数。当向卡片框架发送通知以使指定的卡片可见成功,err
or
为undefined,否则为错误对象。 |
**错误码:**
| 错误码ID | 错误信息 |
| -------- | -------- |
| 401 |
If the input parameter is not valid parameter.
|
以上错误码的详细介绍请参见
[
卡片错误码
](
../errorcodes/errorcode-form.md
)
。
| 401 |
调用接口入参错误。
|
|以上错误码的详细介绍请参见
[
卡片错误码
](
../errorcodes/errorcode-form.md
)
。||
**示例:**
```
ts
try
{
var
formId
=
[
"
12400633174999288
"
];
formHost
.
notifyVisibleForms
(
formId
,
(
error
,
data
)
=>
{
let
formId
=
[
"
12400633174999288
"
];
formHost
.
notifyVisibleForms
(
formId
,
(
error
)
=>
{
if
(
error
)
{
console
.
log
(
'
formHost notifyVisibleForms, error:
'
+
JSON
.
stringify
(
error
)
);
console
.
log
(
`error, code:
${
error
.
code
}
, message:
${
error
.
message
}
)`
);
}
});
}
catch
(
error
)
{
console
.
log
(
`catch err
->
${
JSON
.
stringify
(
error
)}
`
);
console
.
log
(
`catch err
or, code:
${
error
.
code
}
, message:
${
error
.
message
}
)
`
);
}
```
...
...
@@ -456,21 +455,21 @@ notifyVisibleForms(formIds: Array<string>): Promise<void>
| 错误码ID | 错误信息 |
| -------- | -------- |
| 401 |
If the input parameter is not valid parameter.
|
以上错误码的详细介绍请参见
[
卡片错误码
](
../errorcodes/errorcode-form.md
)
。
| 401 |
调用接口入参错误。
|
|以上错误码的详细介绍请参见
[
卡片错误码
](
../errorcodes/errorcode-form.md
)
。||
**示例:**
```
ts
try
{
var
formId
=
[
"
12400633174999288
"
];
let
formId
=
[
"
12400633174999288
"
];
formHost
.
notifyVisibleForms
(
formId
).
then
(()
=>
{
console
.
log
(
'
formHost notifyVisibleForms success
'
);
}).
catch
((
error
)
=>
{
console
.
log
(
'
formHost notifyVisibleForms, error:
'
+
JSON
.
stringify
(
error
)
);
console
.
log
(
`error, code:
${
error
.
code
}
, message:
${
error
.
message
}
)`
);
});
}
catch
(
error
)
{
console
.
log
(
`catch err
->
${
JSON
.
stringify
(
error
)}
`
);
console
.
log
(
`catch err
or, code:
${
error
.
code
}
, message:
${
error
.
message
}
)
`
);
}
```
...
...
@@ -489,27 +488,27 @@ notifyInvisibleForms(formIds: Array<string>, callback: AsyncCallback<vo
| 参数名 | 类型 | 必填 | 说明 |
| ------ | ------ | ---- | ------- |
| formIds | Array
<
string
>
| 是 | 卡片标识列表。|
| callback | AsyncCallback
<
void
>
| 是 | 回调函数。当向卡片框架发送通知以使指定的卡片不可见成功,err为undefined,否则为错误对象。 |
| callback | AsyncCallback
<
void
>
| 是 | 回调函数。当向卡片框架发送通知以使指定的卡片不可见成功,err
or
为undefined,否则为错误对象。 |
**错误码:**
| 错误码ID | 错误信息 |
| -------- | -------- |
| 401 |
If the input parameter is not valid parameter.
|
以上错误码的详细介绍请参见
[
卡片错误码
](
../errorcodes/errorcode-form.md
)
。
| 401 |
调用接口入参错误。
|
|以上错误码的详细介绍请参见
[
卡片错误码
](
../errorcodes/errorcode-form.md
)
。||
**示例:**
```
ts
try
{
var
formId
=
[
"
12400633174999288
"
];
formHost
.
notifyInvisibleForms
(
formId
,
(
error
,
data
)
=>
{
let
formId
=
[
"
12400633174999288
"
];
formHost
.
notifyInvisibleForms
(
formId
,
(
error
)
=>
{
if
(
error
)
{
console
.
log
(
'
formHost notifyInvisibleForms, error:
'
+
JSON
.
stringify
(
error
)
);
console
.
log
(
`error, code:
${
error
.
code
}
, message:
${
error
.
message
}
)`
);
}
});
}
catch
(
error
)
{
console
.
log
(
`catch err
->
${
JSON
.
stringify
(
error
)}
`
);
console
.
log
(
`catch err
or, code:
${
error
.
code
}
, message:
${
error
.
message
}
)
`
);
}
```
...
...
@@ -539,21 +538,21 @@ notifyInvisibleForms(formIds: Array<string>): Promise<void>
| 错误码ID | 错误信息 |
| -------- | -------- |
| 401 |
If the input parameter is not valid parameter.
|
以上错误码的详细介绍请参见
[
卡片错误码
](
../errorcodes/errorcode-form.md
)
。
| 401 |
调用接口入参错误。
|
|以上错误码的详细介绍请参见
[
卡片错误码
](
../errorcodes/errorcode-form.md
)
。||
**示例:**
```
ts
try
{
var
formId
=
[
"
12400633174999288
"
];
let
formId
=
[
"
12400633174999288
"
];
formHost
.
notifyInvisibleForms
(
formId
).
then
(()
=>
{
console
.
log
(
'
formHost notifyInvisibleForms success
'
);
}).
catch
((
error
)
=>
{
console
.
log
(
'
formHost notifyInvisibleForms, error:
'
+
JSON
.
stringify
(
error
)
);
console
.
log
(
`error, code:
${
error
.
code
}
, message:
${
error
.
message
}
)`
);
});
}
catch
(
error
)
{
console
.
log
(
`catch err
->
${
JSON
.
stringify
(
error
)}
`
);
console
.
log
(
`catch err
or, code:
${
error
.
code
}
, message:
${
error
.
message
}
)
`
);
}
```
...
...
@@ -572,27 +571,27 @@ enableFormsUpdate(formIds: Array<string>, callback: AsyncCallback<void&
| 参数名 | 类型 | 必填 | 说明 |
| ------ | ------ | ---- | ------- |
| formIds | Array
<
string
>
| 是 | 卡片标识列表。 |
| callback | AsyncCallback
<
void
>
| 是 | 回调函数。当向卡片框架发送通知以使指定的卡片可以更新成功,err为undefined,否则为错误对象。 |
| callback | AsyncCallback
<
void
>
| 是 | 回调函数。当向卡片框架发送通知以使指定的卡片可以更新成功,err
or
为undefined,否则为错误对象。 |
**错误码:**
| 错误码ID | 错误信息 |
| -------- | -------- |
| 401 |
If the input parameter is not valid parameter.
|
以上错误码的详细介绍请参见
[
卡片错误码
](
../errorcodes/errorcode-form.md
)
。
| 401 |
调用接口入参错误。
|
|以上错误码的详细介绍请参见
[
卡片错误码
](
../errorcodes/errorcode-form.md
)
。||
**示例:**
```
ts
try
{
var
formId
=
[
"
12400633174999288
"
];
formHost
.
enableFormsUpdate
(
formId
,
(
error
,
data
)
=>
{
let
formId
=
[
"
12400633174999288
"
];
formHost
.
enableFormsUpdate
(
formId
,
(
error
)
=>
{
if
(
error
)
{
console
.
log
(
'
formHost enableFormsUpdate, error:
'
+
JSON
.
stringify
(
error
)
);
console
.
log
(
`error, code:
${
error
.
code
}
, message:
${
error
.
message
}
)`
);
}
});
}
catch
(
error
)
{
console
.
log
(
`catch err
->
${
JSON
.
stringify
(
error
)}
`
);
console
.
log
(
`catch err
or, code:
${
error
.
code
}
, message:
${
error
.
message
}
)
`
);
}
```
...
...
@@ -622,21 +621,21 @@ enableFormsUpdate(formIds: Array<string>): Promise<void>
| 错误码ID | 错误信息 |
| -------- | -------- |
| 401 |
If the input parameter is not valid parameter.
|
以上错误码的详细介绍请参见
[
卡片错误码
](
../errorcodes/errorcode-form.md
)
。
| 401 |
调用接口入参错误。
|
|以上错误码的详细介绍请参见
[
卡片错误码
](
../errorcodes/errorcode-form.md
)
。||
**示例:**
```
ts
try
{
var
formId
=
[
"
12400633174999288
"
];
let
formId
=
[
"
12400633174999288
"
];
formHost
.
enableFormsUpdate
(
formId
).
then
(()
=>
{
console
.
log
(
'
formHost enableFormsUpdate success
'
);
}).
catch
((
error
)
=>
{
console
.
log
(
'
formHost enableFormsUpdate, error:
'
+
JSON
.
stringify
(
error
)
);
console
.
log
(
`error, code:
${
error
.
code
}
, message:
${
error
.
message
}
)`
);
});
}
catch
(
error
)
{
console
.
log
(
`catch err
->
${
JSON
.
stringify
(
error
)}
`
);
console
.
log
(
`catch err
or, code:
${
error
.
code
}
, message:
${
error
.
message
}
)
`
);
}
```
...
...
@@ -655,27 +654,27 @@ disableFormsUpdate(formIds: Array<string>, callback: AsyncCallback<void
| 参数名 | 类型 | 必填 | 说明 |
| ------ | ------ | ---- | ------- |
| formIds | Array
<
string
>
| 是 | 卡片标识列表。 |
| callback | AsyncCallback
<
void
>
| 是 | 回调函数。当向卡片框架发送通知以使指定的卡片不可以更新成功,err为undefined,否则为错误对象。 |
| callback | AsyncCallback
<
void
>
| 是 | 回调函数。当向卡片框架发送通知以使指定的卡片不可以更新成功,err
or
为undefined,否则为错误对象。 |
**错误码:**
| 错误码ID | 错误信息 |
| -------- | -------- |
| 401 |
If the input parameter is not valid parameter.
|
以上错误码的详细介绍请参见
[
卡片错误码
](
../errorcodes/errorcode-form.md
)
。
| 401 |
调用接口入参错误。
|
|以上错误码的详细介绍请参见
[
卡片错误码
](
../errorcodes/errorcode-form.md
)
。||
**示例:**
```
ts
try
{
var
formId
=
[
"
12400633174999288
"
];
formHost
.
disableFormsUpdate
(
formId
,
(
error
,
data
)
=>
{
let
formId
=
[
"
12400633174999288
"
];
formHost
.
disableFormsUpdate
(
formId
,
(
error
)
=>
{
if
(
error
)
{
console
.
log
(
'
formHost disableFormsUpdate, error:
'
+
JSON
.
stringify
(
error
)
);
console
.
log
(
`error, code:
${
error
.
code
}
, message:
${
error
.
message
}
)`
);
}
});
}
catch
(
error
)
{
console
.
log
(
`catch err
->
${
JSON
.
stringify
(
error
)}
`
);
console
.
log
(
`catch err
or, code:
${
error
.
code
}
, message:
${
error
.
message
}
)
`
);
}
```
...
...
@@ -705,21 +704,21 @@ disableFormsUpdate(formIds: Array<string>): Promise<void>
| 错误码ID | 错误信息 |
| -------- | -------- |
| 401 |
If the input parameter is not valid parameter.
|
以上错误码的详细介绍请参见
[
卡片错误码
](
../errorcodes/errorcode-form.md
)
。
| 401 |
调用接口入参错误。
|
|以上错误码的详细介绍请参见
[
卡片错误码
](
../errorcodes/errorcode-form.md
)
。||
**示例:**
```
ts
try
{
var
formId
=
[
"
12400633174999288
"
];
let
formId
=
[
"
12400633174999288
"
];
formHost
.
disableFormsUpdate
(
formId
).
then
(()
=>
{
console
.
log
(
'
formHost disableFormsUpdate success
'
);
}).
catch
((
error
)
=>
{
console
.
log
(
'
formHost disableFormsUpdate, error:
'
+
JSON
.
stringify
(
error
)
);
console
.
log
(
`error, code:
${
error
.
code
}
, message:
${
error
.
message
}
)`
);
});
}
catch
(
error
)
{
console
.
log
(
`catch err
->
${
JSON
.
stringify
(
error
)}
`
);
console
.
log
(
`catch err
or, code:
${
error
.
code
}
, message:
${
error
.
message
}
)
`
);
}
```
...
...
@@ -735,20 +734,19 @@ isSystemReady(callback: AsyncCallback<void>): void
| 参数名 | 类型 | 必填 | 说明 |
| ------ | ------ | ---- | ------- |
| callback | AsyncCallback
<
void
>
| 是 | 回调函数。当检查系统是否准备好成功,err为undefined,否则为错误对象。 |
| callback | AsyncCallback
<
void
>
| 是 | 回调函数。当检查系统是否准备好成功,err
or
为undefined,否则为错误对象。 |
**示例:**
```
ts
try
{
var
formId
=
"
12400633174999288
"
;
formHost
.
isSystemReady
((
error
,
data
)
=>
{
if
(
error
)
{
console
.
log
(
'
formHost isSystemReady, error:
'
+
JSON
.
stringify
(
error
)
);
console
.
log
(
`error, code:
${
error
.
code
}
, message:
${
error
.
message
}
)`
);
}
});
}
catch
(
error
)
{
console
.
log
(
`catch err
->
${
JSON
.
stringify
(
error
)}
`
);
console
.
log
(
`catch err
or, code:
${
error
.
code
}
, message:
${
error
.
message
}
)
`
);
}
```
...
...
@@ -770,14 +768,13 @@ isSystemReady(): Promise<void>
```
ts
try
{
var
formId
=
"
12400633174999288
"
;
formHost
.
isSystemReady
().
then
(()
=>
{
console
.
log
(
'
formHost isSystemReady success
'
);
}).
catch
((
error
)
=>
{
console
.
log
(
'
formHost isSystemReady, error:
'
+
JSON
.
stringify
(
error
)
);
console
.
log
(
`error, code:
${
error
.
code
}
, message:
${
error
.
message
}
)`
);
});
}
catch
(
error
)
{
console
.
log
(
`catch err
->
${
JSON
.
stringify
(
error
)}
`
);
console
.
log
(
`catch err
or, code:
${
error
.
code
}
, message:
${
error
.
message
}
)
`
);
}
```
...
...
@@ -795,7 +792,7 @@ getAllFormsInfo(callback: AsyncCallback<Array<formInfo.FormInfo>>):
| 参数名 | 类型 | 必填 | 说明 |
| ------ | ------ | ---- | ------- |
| callback | AsyncCallback
<
Array
<
[
FormInfo](js-apis-app-form-formInfo.md)
>>
| 是 | 回调函数。当获取设备上所有应用提供的卡片信息成功,er
r为undefined,data为查询到的卡片信息;否则为错误对象。 |
| callback | AsyncCallback
<
Array
<
[
formInfo.FormInfo](js-apis-app-form-formInfo.md)
>>
| 是 | 回调函数。当获取设备上所有应用提供的卡片信息成功,erro
r为undefined,data为查询到的卡片信息;否则为错误对象。 |
**示例:**
...
...
@@ -803,13 +800,13 @@ getAllFormsInfo(callback: AsyncCallback<Array<formInfo.FormInfo>>):
try
{
formHost
.
getAllFormsInfo
((
error
,
data
)
=>
{
if
(
error
)
{
console
.
log
(
'
formHost getAllFormsInfo, error:
'
+
JSON
.
stringify
(
error
)
);
console
.
log
(
`error, code:
${
error
.
code
}
, message:
${
error
.
message
}
)`
);
}
else
{
console
.
log
(
'
formHost getAllFormsInfo, data:
'
+
JSON
.
stringify
(
data
));
}
});
}
catch
(
error
)
{
console
.
log
(
`catch err
->
${
JSON
.
stringify
(
error
)}
`
);
console
.
log
(
`catch err
or, code:
${
error
.
code
}
, message:
${
error
.
message
}
)
`
);
}
```
...
...
@@ -825,9 +822,9 @@ getAllFormsInfo(): Promise<Array<formInfo.FormInfo>>
**返回值:**
| 类型 | 说明 |
| :------------ | :---------------------------------- |
| Promise
<
Array
<
[FormInfo](js-apis-app-form-formInfo.md)
>>
| Promise对象,返回查询到的卡片信息。 |
| 类型
| 说明 |
| :------------
-----------------------------------------------
| :---------------------------------- |
| Promise
<
Array
<
[
formInfo.
FormInfo](js-apis-app-form-formInfo.md)
>>
| Promise对象,返回查询到的卡片信息。 |
**示例:**
...
...
@@ -836,10 +833,10 @@ try {
formHost
.
getAllFormsInfo
().
then
((
data
)
=>
{
console
.
log
(
'
formHost getAllFormsInfo data:
'
+
JSON
.
stringify
(
data
));
}).
catch
((
error
)
=>
{
console
.
log
(
'
formHost getAllFormsInfo, error:
'
+
JSON
.
stringify
(
error
)
);
console
.
log
(
`error, code:
${
error
.
code
}
, message:
${
error
.
message
}
)`
);
});
}
catch
(
error
)
{
console
.
log
(
`catch err
->
${
JSON
.
stringify
(
error
)}
`
);
console
.
log
(
`catch err
or, code:
${
error
.
code
}
, message:
${
error
.
message
}
)
`
);
}
```
...
...
@@ -858,14 +855,14 @@ getFormsInfo(bundleName: string, callback: AsyncCallback<Array<formInfo.Fo
| 参数名 | 类型 | 必填 | 说明 |
| ------ | ------ | ---- | ------- |
| bundleName | string | 是 | 要查询的应用Bundle名称。 |
| callback | AsyncCallback
<
Array
<
[
FormInfo](js-apis-app-form-formInfo.md)
>>
| 是 | 回调函数。当获取设备上指定应用程序提供的卡片信息成功,er
r为undefined,data为查询到的卡片信息;否则为错误对象。 |
| callback | AsyncCallback
<
Array
<
[
formInfo.FormInfo](js-apis-app-form-formInfo.md)
>>
| 是 | 回调函数。当获取设备上指定应用程序提供的卡片信息成功,erro
r为undefined,data为查询到的卡片信息;否则为错误对象。 |
**错误码:**
| 错误码ID | 错误信息 |
| -------- | -------- |
| 401 |
If the input parameter is not valid parameter.
|
以上错误码的详细介绍请参见
[
卡片错误码
](
../errorcodes/errorcode-form.md
)
。
| 401 |
调用接口入参错误。
|
|以上错误码的详细介绍请参见
[
卡片错误码
](
../errorcodes/errorcode-form.md
)
。||
**示例:**
...
...
@@ -873,13 +870,13 @@ getFormsInfo(bundleName: string, callback: AsyncCallback<Array<formInfo.Fo
try
{
formHost
.
getFormsInfo
(
"
com.example.ohos.formjsdemo
"
,
(
error
,
data
)
=>
{
if
(
error
)
{
console
.
log
(
'
formHost getFormsInfo, error:
'
+
JSON
.
stringify
(
error
)
);
console
.
log
(
`error, code:
${
error
.
code
}
, message:
${
error
.
message
}
)`
);
}
else
{
console
.
log
(
'
formHost getFormsInfo, data:
'
+
JSON
.
stringify
(
data
));
}
});
}
catch
(
error
)
{
console
.
log
(
`catch err
->
${
JSON
.
stringify
(
error
)}
`
);
console
.
log
(
`catch err
or, code:
${
error
.
code
}
, message:
${
error
.
message
}
)
`
);
}
```
...
...
@@ -899,14 +896,14 @@ getFormsInfo(bundleName: string, moduleName: string, callback: AsyncCallback<
| ------ | ------ | ---- | ------- |
| bundleName | string | 是 | 要查询的应用Bundle名称。 |
| moduleName | string | 是 | 要查询的模块名称。 |
| callback | AsyncCallback
<
Array
<
[
FormInfo](js-apis-app-form-formInfo.md)
>>
| 是 | 回调函数。当获取设备上指定应用程序提供的卡片信息成功,er
r为undefined,data为查询到的卡片信息;否则为错误对象。 |
| callback | AsyncCallback
<
Array
<
[
formInfo.FormInfo](js-apis-app-form-formInfo.md)
>>
| 是 | 回调函数。当获取设备上指定应用程序提供的卡片信息成功,erro
r为undefined,data为查询到的卡片信息;否则为错误对象。 |
**错误码:**
| 错误码ID | 错误信息 |
| -------- | -------- |
| 401 |
If the input parameter is not valid parameter.
|
以上错误码的详细介绍请参见
[
卡片错误码
](
../errorcodes/errorcode-form.md
)
。
| 401 |
调用接口入参错误。
|
|以上错误码的详细介绍请参见
[
卡片错误码
](
../errorcodes/errorcode-form.md
)
。||
**示例:**
...
...
@@ -914,13 +911,13 @@ getFormsInfo(bundleName: string, moduleName: string, callback: AsyncCallback<
try
{
formHost
.
getFormsInfo
(
"
com.example.ohos.formjsdemo
"
,
"
entry
"
,
(
error
,
data
)
=>
{
if
(
error
)
{
console
.
log
(
'
formHost getFormsInfo, error:
'
+
JSON
.
stringify
(
error
)
);
console
.
log
(
`error, code:
${
error
.
code
}
, message:
${
error
.
message
}
)`
);
}
else
{
console
.
log
(
'
formHost getFormsInfo, data:
'
+
JSON
.
stringify
(
data
));
}
});
}
catch
(
error
)
{
console
.
log
(
`catch err
->
${
JSON
.
stringify
(
error
)}
`
);
console
.
log
(
`catch err
or, code:
${
error
.
code
}
, message:
${
error
.
message
}
)
`
);
}
```
...
...
@@ -943,16 +940,16 @@ getFormsInfo(bundleName: string, moduleName?: string): Promise<Array<formI
**返回值:**
| 类型 | 说明 |
| :------------ | :---------------------------------- |
| Promise
<
Array
<
[FormInfo](js-apis-app-form-formInfo.md)
>>
| Promise对象,返回查询到的卡片信息。 |
| 类型
| 说明 |
| :------------
-----------------------------------------------
| :---------------------------------- |
| Promise
<
Array
<
[
formInfo.
FormInfo](js-apis-app-form-formInfo.md)
>>
| Promise对象,返回查询到的卡片信息。 |
**错误码:**
| 错误码ID | 错误信息 |
| -------- | -------- |
| 401 |
If the input parameter is not valid parameter.
|
以上错误码的详细介绍请参见
[
卡片错误码
](
../errorcodes/errorcode-form.md
)
。
| 401 |
调用接口入参错误。
|
|以上错误码的详细介绍请参见
[
卡片错误码
](
../errorcodes/errorcode-form.md
)
。||
**示例:**
...
...
@@ -961,10 +958,10 @@ try {
formHost
.
getFormsInfo
(
"
com.example.ohos.formjsdemo
"
,
"
entry
"
).
then
((
data
)
=>
{
console
.
log
(
'
formHost getFormsInfo, data:
'
+
JSON
.
stringify
(
data
));
}).
catch
((
error
)
=>
{
console
.
log
(
'
formHost getFormsInfo, error:
'
+
JSON
.
stringify
(
error
)
);
console
.
log
(
`error, code:
${
error
.
code
}
, message:
${
error
.
message
}
)`
);
});
}
catch
(
error
)
{
console
.
log
(
`catch err
->
${
JSON
.
stringify
(
error
)}
`
);
console
.
log
(
`catch err
or, code:
${
error
.
code
}
, message:
${
error
.
message
}
)
`
);
}
```
...
...
@@ -983,22 +980,22 @@ deleteInvalidForms(formIds: Array<string>, callback: AsyncCallback<numb
| 参数名 | 类型 | 必填 | 说明 |
| ------ | ------ | ---- | ------- |
| formIds | Array
<
string
>
| 是 | 有效卡片标识列表。 |
| callback | AsyncCallback
<
number
>
| 是 | 回调函数。当根据列表删除应用程序的无效卡片成功,err为undefined,data为删除的卡片个数;否则为错误对象。 |
| callback | AsyncCallback
<
number
>
| 是 | 回调函数。当根据列表删除应用程序的无效卡片成功,err
or
为undefined,data为删除的卡片个数;否则为错误对象。 |
**示例:**
```
ts
try
{
var
formIds
=
new
Array
(
"
12400633174999288
"
,
"
12400633174999289
"
);
let
formIds
=
new
Array
(
"
12400633174999288
"
,
"
12400633174999289
"
);
formHost
.
deleteInvalidForms
(
formIds
,
(
error
,
data
)
=>
{
if
(
error
)
{
console
.
log
(
'
formHost deleteInvalidForms, error:
'
+
JSON
.
stringify
(
error
)
);
console
.
log
(
`error, code:
${
error
.
code
}
, message:
${
error
.
message
}
)`
);
}
else
{
console
.
log
(
'
formHost deleteInvalidForms, data:
'
+
JSON
.
stringify
(
data
));
}
});
}
catch
(
error
)
{
console
.
log
(
`catch err
->
${
JSON
.
stringify
(
error
)}
`
);
console
.
log
(
`catch err
or, code:
${
error
.
code
}
, message:
${
error
.
message
}
)
`
);
}
```
...
...
@@ -1028,14 +1025,14 @@ deleteInvalidForms(formIds: Array<string>): Promise<number>
```
ts
try
{
var
formIds
=
new
Array
(
"
12400633174999288
"
,
"
12400633174999289
"
);
let
formIds
=
new
Array
(
"
12400633174999288
"
,
"
12400633174999289
"
);
formHost
.
deleteInvalidForms
(
formIds
).
then
((
data
)
=>
{
console
.
log
(
'
formHost deleteInvalidForms, data:
'
+
JSON
.
stringify
(
data
));
}).
catch
((
error
)
=>
{
console
.
log
(
'
formHost deleteInvalidForms, error:
'
+
JSON
.
stringify
(
error
)
);
console
.
log
(
`error, code:
${
error
.
code
}
, message:
${
error
.
message
}
)`
);
});
}
catch
(
error
)
{
console
.
log
(
`catch err
->
${
JSON
.
stringify
(
error
)}
`
);
console
.
log
(
`catch err
or, code:
${
error
.
code
}
, message:
${
error
.
message
}
)
`
);
}
```
...
...
@@ -1053,15 +1050,15 @@ acquireFormState(want: Want, callback: AsyncCallback<formInfo.FormStateInfo&g
| 参数名 | 类型 | 必填 | 说明 |
| ------ | ------ | ---- | ------- |
| want |
[
Want
](
js-apis-application-want.md
)
| 是 | 查询卡片状态时携带的want信息。 |
| callback | AsyncCallback
<
[
FormStateInfo](js-apis-app-form-formInfo.md#formstateinfo)
>
| 是 | 回调函数。当获取卡片状态成功,er
r为undefined,data为获取到的卡片状态;否则为错误对象。 |
| want |
[
Want
](
js-apis-application-want.md
)
| 是 | 查询卡片状态时携带的want信息。
需要包含bundle名、ability名、module名、卡片名、卡片规格等。
|
| callback | AsyncCallback
<
[
formInfo.FormStateInfo](js-apis-app-form-formInfo.md#formstateinfo)
>
| 是 | 回调函数。当获取卡片状态成功,erro
r为undefined,data为获取到的卡片状态;否则为错误对象。 |
**错误码:**
| 错误码ID | 错误信息 |
| -------- | -------- |
| 401 |
If the input parameter is not valid parameter.
|
以上错误码的详细介绍请参见
[
卡片错误码
](
../errorcodes/errorcode-form.md
)
。
| 401 |
调用接口入参错误。
|
|以上错误码的详细介绍请参见
[
卡片错误码
](
../errorcodes/errorcode-form.md
)
。||
**示例:**
...
...
@@ -1079,13 +1076,13 @@ var want = {
try
{
formHost
.
acquireFormState
(
want
,
(
error
,
data
)
=>
{
if
(
error
)
{
console
.
log
(
'
formHost acquireFormState, error:
'
+
JSON
.
stringify
(
error
)
);
console
.
log
(
`error, code:
${
error
.
code
}
, message:
${
error
.
message
}
)`
);
}
else
{
console
.
log
(
'
formHost acquireFormState, data:
'
+
JSON
.
stringify
(
data
));
}
});
}
catch
(
error
)
{
console
.
log
(
`catch err
->
${
JSON
.
stringify
(
error
)}
`
);
console
.
log
(
`catch err
or, code:
${
error
.
code
}
, message:
${
error
.
message
}
)
`
);
}
```
...
...
@@ -1103,20 +1100,20 @@ acquireFormState(want: Want): Promise<formInfo.FormStateInfo>
| 参数名 | 类型 | 必填 | 说明 |
| ------ | ------ | ---- | ------- |
| want |
[
Want
](
js-apis-application-want.md
)
| 是 | 查询卡片状态时携带的want信息。 |
| want |
[
Want
](
js-apis-application-want.md
)
| 是 | 查询卡片状态时携带的want信息。
需要包含bundle名、ability名、module名、卡片名、卡片规格等。
|
**返回值:**
| 类型 | 说明 |
| :------------ | :---------------------------------- |
| Promise
<
[FormStateInfo](js-apis-app-form-formInfo.md#formstateinfo)
>
| Promise对象,返回卡片状态。 |
| Promise
<
[
formInfo.
FormStateInfo](js-apis-app-form-formInfo.md#formstateinfo)
>
| Promise对象,返回卡片状态。 |
**错误码:**
| 错误码ID | 错误信息 |
| -------- | -------- |
| 401 |
If the input parameter is not valid parameter.
|
以上错误码的详细介绍请参见
[
卡片错误码
](
../errorcodes/errorcode-form.md
)
。
| 401 |
调用接口入参错误。
|
|以上错误码的详细介绍请参见
[
卡片错误码
](
../errorcodes/errorcode-form.md
)
。||
**示例:**
...
...
@@ -1135,10 +1132,10 @@ try {
formHost
.
acquireFormState
(
want
).
then
((
data
)
=>
{
console
.
log
(
'
formHost acquireFormState, data:
'
+
JSON
.
stringify
(
data
));
}).
catch
((
error
)
=>
{
console
.
log
(
'
formHost acquireFormState, error:
'
+
JSON
.
stringify
(
error
)
);
console
.
log
(
`error, code:
${
error
.
code
}
, message:
${
error
.
message
}
)`
);
});
}
catch
(
error
)
{
console
.
log
(
`catch err
->
${
JSON
.
stringify
(
error
)}
`
);
console
.
log
(
`catch err
or, code:
${
error
.
code
}
, message:
${
error
.
message
}
)
`
);
}
```
...
...
@@ -1206,27 +1203,27 @@ notifyFormsVisible(formIds: Array<string>, isVisible: boolean, callback: A
| ------ | ------ | ---- | ------- |
| formIds | Array
<
string
>
| 是 | 卡片标识列表。 |
| isVisible | boolean | 是 | 是否可见。 |
| callback | AsyncCallback
<
void
>
| 是 | 回调函数。当通知卡片是否可见成功,err为undefined,否则为错误对象。 |
| callback | AsyncCallback
<
void
>
| 是 | 回调函数。当通知卡片是否可见成功,err
or
为undefined,否则为错误对象。 |
**错误码:**
| 错误码ID | 错误信息 |
| -------- | -------- |
| 401 |
If the input parameter is not valid parameter.
|
以上错误码的详细介绍请参见
[
卡片错误码
](
../errorcodes/errorcode-form.md
)
。
| 401 |
调用接口入参错误。
|
|以上错误码的详细介绍请参见
[
卡片错误码
](
../errorcodes/errorcode-form.md
)
。||
**示例:**
```
ts
var
formIds
=
new
Array
(
"
12400633174999288
"
,
"
12400633174999289
"
);
let
formIds
=
new
Array
(
"
12400633174999288
"
,
"
12400633174999289
"
);
try
{
formHost
.
notifyFormsVisible
(
formIds
,
true
,
(
error
,
data
)
=>
{
formHost
.
notifyFormsVisible
(
formIds
,
true
,
(
error
)
=>
{
if
(
error
)
{
console
.
log
(
'
formHost notifyFormsVisible, error:
'
+
JSON
.
stringify
(
error
)
);
console
.
log
(
`error, code:
${
error
.
code
}
, message:
${
error
.
message
}
)`
);
}
});
}
catch
(
error
)
{
console
.
log
(
`catch err
->
${
JSON
.
stringify
(
error
)}
`
);
console
.
log
(
`catch err
or, code:
${
error
.
code
}
, message:
${
error
.
message
}
)
`
);
}
```
...
...
@@ -1257,21 +1254,21 @@ notifyFormsVisible(formIds: Array<string>, isVisible: boolean): Promise<
| 错误码ID | 错误信息 |
| -------- | -------- |
| 401 |
If the input parameter is not valid parameter.
|
以上错误码的详细介绍请参见
[
卡片错误码
](
../errorcodes/errorcode-form.md
)
。
| 401 |
调用接口入参错误。
|
|以上错误码的详细介绍请参见
[
卡片错误码
](
../errorcodes/errorcode-form.md
)
。||
**示例:**
```
ts
var
formIds
=
new
Array
(
"
12400633174999288
"
,
"
12400633174999289
"
);
let
formIds
=
new
Array
(
"
12400633174999288
"
,
"
12400633174999289
"
);
try
{
formHost
.
notifyFormsVisible
(
formIds
,
true
).
then
(()
=>
{
console
.
log
(
'
formHost notifyFormsVisible success
'
);
}).
catch
((
error
)
=>
{
console
.
log
(
'
formHost notifyFormsVisible, error:
'
+
JSON
.
stringify
(
error
)
);
console
.
log
(
`error, code:
${
error
.
code
}
, message:
${
error
.
message
}
)`
);
});
}
catch
(
error
)
{
console
.
log
(
`catch err
->
${
JSON
.
stringify
(
error
)}
`
);
console
.
log
(
`catch err
or, code:
${
error
.
code
}
, message:
${
error
.
message
}
)
`
);
}
```
...
...
@@ -1291,27 +1288,27 @@ notifyFormsEnableUpdate(formIds: Array<string>, isEnableUpdate: boolean, c
| ------ | ------ | ---- | ------- |
| formIds | Array
<
string
>
| 是 | 卡片标识列表。 |
| isEnableUpdate | boolean | 是 | 是否使能更新。 |
| callback | AsyncCallback
<
void
>
| 是 | 回调函数。当通知卡片是否启用更新状态成功,err为undefined,否则为错误对象。 |
| callback | AsyncCallback
<
void
>
| 是 | 回调函数。当通知卡片是否启用更新状态成功,err
or
为undefined,否则为错误对象。 |
**错误码:**
| 错误码ID | 错误信息 |
| -------- | -------- |
| 401 |
If the input parameter is not valid parameter.
|
以上错误码的详细介绍请参见
[
卡片错误码
](
../errorcodes/errorcode-form.md
)
。
| 401 |
调用接口入参错误。
|
|以上错误码的详细介绍请参见
[
卡片错误码
](
../errorcodes/errorcode-form.md
)
。||
**示例:**
```
ts
var
formIds
=
new
Array
(
"
12400633174999288
"
,
"
12400633174999289
"
);
let
formIds
=
new
Array
(
"
12400633174999288
"
,
"
12400633174999289
"
);
try
{
formHost
.
notifyFormsEnableUpdate
(
formIds
,
true
,
(
error
,
data
)
=>
{
formHost
.
notifyFormsEnableUpdate
(
formIds
,
true
,
(
error
)
=>
{
if
(
error
)
{
console
.
log
(
'
formHost notifyFormsEnableUpdate, error:
'
+
JSON
.
stringify
(
error
)
);
console
.
log
(
`error, code:
${
error
.
code
}
, message:
${
error
.
message
}
)`
);
}
});
}
catch
(
error
)
{
console
.
log
(
`catch err
->
${
JSON
.
stringify
(
error
)}
`
);
console
.
log
(
`catch err
or, code:
${
error
.
code
}
, message:
${
error
.
message
}
)
`
);
}
```
...
...
@@ -1342,21 +1339,21 @@ notifyFormsEnableUpdate(formIds: Array<string>, isEnableUpdate: boolean):
| 错误码ID | 错误信息 |
| -------- | -------- |
| 401 |
If the input parameter is not valid parameter.
|
以上错误码的详细介绍请参见
[
卡片错误码
](
../errorcodes/errorcode-form.md
)
。
| 401 |
调用接口入参错误。
|
|以上错误码的详细介绍请参见
[
卡片错误码
](
../errorcodes/errorcode-form.md
)
。||
**示例:**
```
ts
var
formIds
=
new
Array
(
"
12400633174999288
"
,
"
12400633174999289
"
);
let
formIds
=
new
Array
(
"
12400633174999288
"
,
"
12400633174999289
"
);
try
{
formHost
.
notifyFormsEnableUpdate
(
formIds
,
true
).
then
(()
=>
{
console
.
log
(
'
formHost notifyFormsEnableUpdate success
'
);
}).
catch
((
error
)
=>
{
console
.
log
(
'
formHost notifyFormsEnableUpdate, error:
'
+
JSON
.
stringify
(
error
)
);
console
.
log
(
`error, code:
${
error
.
code
}
, message:
${
error
.
message
}
)`
);
});
}
catch
(
error
)
{
console
.
log
(
`catch err
->
${
JSON
.
stringify
(
error
)}
`
);
console
.
log
(
`catch err
or, code:
${
error
.
code
}
, message:
${
error
.
message
}
)
`
);
}
```
## shareForm
...
...
@@ -1375,29 +1372,28 @@ shareForm(formId: string, deviceId: string, callback: AsyncCallback<void>)
| ------ | ------ | ---- | ------- |
| formId | string | 是 | 卡片标识。 |
| deviceId | string | 是 | 远程设备标识。 |
| callback | AsyncCallback
<
void
>
| 是 | 回调函数。当指定formId和远程设备Id进行卡片分享成功,err为undefined,否则为错误对象。 |
| callback | AsyncCallback
<
void
>
| 是 | 回调函数。当指定formId和远程设备Id进行卡片分享成功,err
or
为undefined,否则为错误对象。 |
**错误码:**
| 错误码ID | 错误信息 |
| -------- | -------- |
| 401 | If the input parameter is not valid parameter. |
以上错误码的详细介绍请参见
[
卡片错误码
](
../errorcodes/errorcode-form.md
)
。
| 401 | 调用接口入参错误。 |
|以上错误码的详细介绍请参见
[
卡片错误码
](
../errorcodes/errorcode-form.md
)
。||
**示例:**
```
ts
var
formId
=
"
12400633174999288
"
;
let
formId
=
"
12400633174999288
"
;
var
deviceId
=
"
EFC11C0C53628D8CC2F8CB5052477E130D075917034613B9884C55CD22B3DEF2
"
;
try
{
formHost
.
shareForm
(
formId
,
deviceId
,
(
error
,
data
)
=>
{
formHost
.
shareForm
(
formId
,
deviceId
,
(
error
)
=>
{
if
(
error
)
{
console
.
log
(
'
formHost shareForm, error:
'
+
JSON
.
stringify
(
error
)
);
console
.
log
(
`error, code:
${
error
.
code
}
, message:
${
error
.
message
}
)`
);
}
});
}
catch
(
error
)
{
console
.
log
(
`catch err
->
${
JSON
.
stringify
(
error
)}
`
);
console
.
log
(
`catch err
or, code:
${
error
.
code
}
, message:
${
error
.
message
}
)
`
);
}
```
...
...
@@ -1428,22 +1424,22 @@ shareForm(formId: string, deviceId: string): Promise<void>
| 错误码ID | 错误信息 |
| -------- | -------- |
| 401 |
If the input parameter is not valid parameter.
|
以上错误码的详细介绍请参见
[
卡片错误码
](
../errorcodes/errorcode-form.md
)
。
| 401 |
调用接口入参错误。
|
|以上错误码的详细介绍请参见
[
卡片错误码
](
../errorcodes/errorcode-form.md
)
。||
**
参数
:**
**
示例
:**
```
ts
var
formId
=
"
12400633174999288
"
;
let
formId
=
"
12400633174999288
"
;
var
deviceId
=
"
EFC11C0C53628D8CC2F8CB5052477E130D075917034613B9884C55CD22B3DEF2
"
;
try
{
formHost
.
shareForm
(
formId
,
deviceId
).
then
(()
=>
{
console
.
log
(
'
formHost shareForm success
'
);
}).
catch
((
error
)
=>
{
console
.
log
(
'
formHost shareForm, error:
'
+
JSON
.
stringify
(
error
)
);
console
.
log
(
`error, code:
${
error
.
code
}
, message:
${
error
.
message
}
)`
);
});
}
catch
(
error
)
{
console
.
log
(
`catch err
->
${
JSON
.
stringify
(
error
)}
`
);
console
.
log
(
`catch err
or, code:
${
error
.
code
}
, message:
${
error
.
message
}
)
`
);
}
```
...
...
@@ -1451,6 +1447,8 @@ try {
notifyFormsPrivacyProtected(formIds: Array
\<
string>, isProtected: boolean, callback: AsyncCallback
\<
void>): void
通知指定卡片隐私保护状态改变。使用callback异步回调。
**需要权限**
:ohos.permission.REQUIRE_FORM
**系统能力**
:SystemCapability.Ability.Form
...
...
@@ -1459,18 +1457,72 @@ notifyFormsPrivacyProtected(formIds: Array\<string>, isProtected: boolean, callb
| 参数名 | 类型 | 必填 | 说明 |
| ------ | ------ | ---- | ------- |
| formId | string | 是 | 卡片标识。 |
| deviceId | string | 是 | 远程设备标识。 |
| formIds | Array
\<
string
\>
| 是 | 需要修改隐私保护的卡片标识列表。 |
| isProtected | boolean | 是 | 是否进行隐私保护。 |
| callback | AsyncCallback
\<
void> | 是 | 回调函数。当指定卡片设置隐私保护属性成功,error为undefined,否则为错误对象。 |
**错误码:**
| 错误码ID | 错误信息 |
| ------------------------------------------------------------ | ------------------ |
| 401 | 调用接口入参错误。 |
| 以上错误码的详细介绍请参见
[
卡片错误码
](
../errorcodes/errorcode-form.md
)
。 | |
**示例:**
```
ts
var
formIds
=
new
Array
(
"
12400633174999288
"
,
"
12400633174999289
"
);
let
formIds
=
new
Array
(
"
12400633174999288
"
,
"
12400633174999289
"
);
try
{
formHost
.
notifyFormsPrivacyProtected
(
formIds
,
true
,
(
error
)
=>
{
if
(
error
)
{
console
.
log
(
`error, code:
${
error
.
code
}
, message:
${
error
.
message
}
)`
);
}
});
}
catch
(
error
)
{
console
.
log
(
`catch error, code:
${
error
.
code
}
, message:
${
error
.
message
}
)`
);
}
```
## notifyFormsPrivacyProtected
function notifyFormsPrivacyProtected(formIds: Array
\<
string
\>
, isProtected: boolean): Promise
\<
void
\>
;
通知指定卡片隐私保护状态改变。使用Promise异步回调。
**需要权限**
:ohos.permission.REQUIRE_FORM
**系统能力**
:SystemCapability.Ability.Form
**参数:**
| 参数名 | 类型 | 必填 | 说明 |
| ----------- | --------------- | ---- | -------------------------------- |
| formIds | Array
\<
string
\>
| 是 | 需要修改隐私保护的卡片标识列表。 |
| isProtected | boolean | 是 | 是否进行隐私保护。 |
**返回值:**
| 类型 | 说明 |
| ------------------- | ------------------------- |
| Promise
<
void
>
| 无返回结果的Promise对象。 |
**错误码:**
| 错误码ID | 错误信息 |
| ------------------------------------------------------------ | ------------------ |
| 401 | 调用接口入参错误。 |
| 以上错误码的详细介绍请参见
[
卡片错误码
](
../errorcodes/errorcode-form.md
)
。 | |
```
ts
let
formIds
=
new
Array
(
"
12400633174999288
"
,
"
12400633174999289
"
);
try
{
formHost
.
notifyFormsPrivacyProtected
(
formIds
,
true
).
then
(()
=>
{
console
.
log
(
'
formHost
shareForm
success
'
);
console
.
log
(
'
formHost
notifyFormsPrivacyProtected
success
'
);
}).
catch
((
error
)
=>
{
console
.
log
(
'
formHost shareForm, error:
'
+
JSON
.
stringify
(
error
)
);
console
.
log
(
`error, code:
${
error
.
code
}
, message:
${
error
.
message
}
)`
);
});
}
catch
(
error
)
{
console
.
log
(
`catch err
->
${
JSON
.
stringify
(
error
)}
`
);
console
.
log
(
`catch err
or, code:
${
error
.
code
}
, message:
${
error
.
message
}
)
`
);
}
```
zh-cn/application-dev/reference/apis/js-apis-app-form-formInfo.md
浏览文件 @
7d07bb0f
# @ohos.app.form.formInfo (
F
ormInfo)
# @ohos.app.form.formInfo (
f
ormInfo)
FormInfo模块提供对卡片的相关卡片信息和状态进行设置和查询的能力
。
formInfo模块提供了卡片信息和状态等相关类型和枚举
。
> **说明:**
>
...
...
@@ -30,11 +30,11 @@ import formInfo from '@ohos.app.form.formInfo';
| colorMode |
[
ColorMode
](
#colormode
)
| 是 | 否 | 卡片颜色模式。 |
| isDefault | boolean | 是 | 否 | 卡片是否是默认卡片。 |
| updateEnabled | boolean | 是 | 否 | 卡片是否使能更新。 |
| formVisibleNotify |
string
| 是 | 否 | 卡片是否使能可见通知。 |
| formVisibleNotify |
boolean
| 是 | 否 | 卡片是否使能可见通知。 |
| relatedBundleName | string | 是 | 否 | 卡片所属的相关联Bundle名称。 |
| scheduledUpdateTime | string | 是 | 否 | 卡片更新时间。 |
| formConfigAbility | string | 是 | 否 | 卡片配置ability。指定长按卡片弹出的选择框内,编辑选项所对应的ability。 |
| updateDuration |
string
| 是 | 否 | 卡片更新周期。 |
| updateDuration |
number
| 是 | 否 | 卡片更新周期。 |
| defaultDimension | number | 是 | 否 | 表示卡片规格 |
| supportDimensions | Array
<
number
>
| 是 | 否 | 卡片支持的规格。具体可选规格参考
[
FormDimension
](
#formdimension
)
|
| customizeData | {[key: string]: [value: string]} | 是 | 否 | 卡片用户数据。 |
...
...
@@ -100,8 +100,8 @@ import formInfo from '@ohos.app.form.formInfo';
| WIDTH_KEY | "ohos.extra.param.key.form_width" | 卡片宽度。 |
| HEIGHT_KEY | "ohos.extra.param.key.form_height" | 卡片高度。 |
| TEMPORARY_KEY | "ohos.extra.param.key.form_temporary" | 临时卡片。 |
| ABILITY_NAME_KEY | "ohos.extra.param.key.ability_name" | ability名称
|
| DEVICE_ID_KEY | "ohos.extra.param.key.device_id" | 设备标识。
<br/>
**系统接口**
: 此接口为系统接口。
|
| ABILITY_NAME_KEY | "ohos.extra.param.key.ability_name" | ability名称
。
|
| DEVICE_ID_KEY | "ohos.extra.param.key.device_id" | 设备标识。 |
| BUNDLE_NAME_KEY | "ohos.extra.param.key.bundle_name" | 指示指定要获取的捆绑Bundle名称的键。 |
## FormDimension
...
...
@@ -127,7 +127,7 @@ import formInfo from '@ohos.app.form.formInfo';
| 名称 | 说明 |
| ----------- | ------------ |
| moduleName |
仅保留moduleName与提供值相符的卡片信息
。 |
| moduleName |
选填。仅保留moduleName与提供值相符的卡片信息。未填写时则不通过moduleName进行过滤
。 |
## VisibilityType
...
...
zh-cn/application-dev/reference/apis/js-apis-app-form-formProvider.md
浏览文件 @
7d07bb0f
# @ohos.app.form.formProvider (
F
ormProvider)
# @ohos.app.form.formProvider (
f
ormProvider)
FormProvider模块提供了卡片提供方相关接口的能力,开发者在开发卡片时,可通过该模块提供接口实现更新卡片
,设置卡片更新时间,获取卡片信息,
请求发布卡片等。
FormProvider模块提供了卡片提供方相关接口的能力,开发者在开发卡片时,可通过该模块提供接口实现更新卡片
、设置卡片更新时间、获取卡片信息、
请求发布卡片等。
> **说明:**
> 本模块首批接口从API version 9开始支持。后续版本的新增接口,采用上角标单独标记接口的起始版本。
...
...
@@ -31,23 +31,25 @@ setFormNextRefreshTime(formId: string, minute: number, callback: AsyncCallback&l
| 错误码ID | 错误信息 |
| -------- | -------- |
| 401 |
If the input parameter is not valid parameter.
|
以上错误码的详细介绍请参见
[
卡片错误码
](
../errorcodes/errorcode-form.md
)
。
| 401 |
调用接口入参错误。
|
|以上错误码的详细介绍请参见
[
卡片错误码
](
../errorcodes/errorcode-form.md
)
。||
**示例:**
```
ts
var
formId
=
"
12400633174999288
"
;
import
formProvider
from
'
@ohos.app.form.formProvider
'
;
let
formId
=
"
12400633174999288
"
;
try
{
formProvider
.
setFormNextRefreshTime
(
formId
,
5
,
(
error
,
data
)
=>
{
if
(
error
)
{
console
.
log
(
'
formProvider setFormNextRefreshTime, error:
'
+
JSON
.
stringify
(
error
)
);
console
.
log
(
`callback error, code:
${
error
.
code
}
, message:
${
error
.
message
}
)`
);
}
else
{
console
.
log
(
`formProvider setFormNextRefreshTime success`
);
}
});
}
catch
(
error
)
{
console
.
log
(
"
error
"
+
JSON
.
stringify
(
error
))
console
.
log
(
`catch error, code:
${
error
.
code
}
, message:
${
error
.
message
}
)`
);
}
```
...
...
@@ -76,21 +78,23 @@ setFormNextRefreshTime(formId: string, minute: number): Promise<void>
| 错误码ID | 错误信息 |
| -------- | -------- |
| 401 |
If the input parameter is not valid parameter.
|
以上错误码的详细介绍请参见
[
卡片错误码
](
../errorcodes/errorcode-form.md
)
。
| 401 |
调用接口入参错误。
|
|以上错误码的详细介绍请参见
[
卡片错误码
](
../errorcodes/errorcode-form.md
)
。||
**示例:**
```
ts
var
formId
=
"
12400633174999288
"
;
import
formProvider
from
'
@ohos.app.form.formProvider
'
;
let
formId
=
"
12400633174999288
"
;
try
{
formProvider
.
setFormNextRefreshTime
(
formId
,
5
).
then
(()
=>
{
console
.
log
(
'
formProvider setFormNextRefreshTime success
'
);
console
.
log
(
`formProvider setFormNextRefreshTime success`
);
}).
catch
((
error
)
=>
{
console
.
log
(
'
formProvider setFormNextRefreshTime, error:
'
+
JSON
.
stringify
(
error
)
);
console
.
log
(
`promise error, code:
${
error
.
code
}
, message:
${
error
.
message
}
)`
);
});
}
catch
(
error
)
{
console
.
log
(
`catch err
->
${
JSON
.
stringify
(
error
)}
`
);
console
.
log
(
`catch err
or, code:
${
error
.
code
}
, message:
${
error
.
message
}
)
`
);
}
```
...
...
@@ -114,25 +118,27 @@ updateForm(formId: string, formBindingData: formBindingData.FormBindingData,call
| 错误码ID | 错误信息 |
| -------- | -------- |
| 401 |
If the input parameter is not valid parameter.
|
以上错误码的详细介绍请参见
[
卡片错误码
](
../errorcodes/errorcode-form.md
)
。
| 401 |
调用接口入参错误。
|
|以上错误码的详细介绍请参见
[
卡片错误码
](
../errorcodes/errorcode-form.md
)
。||
**示例:**
```
ts
import
formBindingData
from
'
@ohos.application.formBindingData
'
;
var
formId
=
"
12400633174999288
"
;
import
formProvider
from
'
@ohos.app.form.formProvider
'
;
let
formId
=
"
12400633174999288
"
;
try
{
let
obj
=
formBindingData
.
createFormBindingData
({
temperature
:
"
22c
"
,
time
:
"
22:00
"
});
formProvider
.
updateForm
(
formId
,
obj
,
(
error
,
data
)
=>
{
if
(
error
)
{
console
.
log
(
'
formProvider updateForm, error:
'
+
JSON
.
stringify
(
error
)
);
console
.
log
(
`callback error, code:
${
error
.
code
}
, message:
${
error
.
message
}
)`
);
}
else
{
console
.
log
(
`formProvider updateForm success`
);
}
});
}
catch
(
error
)
{
console
.
log
(
`catch err
->
${
JSON
.
stringify
(
error
)}
`
);
console
.
log
(
`catch err
or, code:
${
error
.
code
}
, message:
${
error
.
message
}
)
`
);
}
```
...
...
@@ -161,23 +167,25 @@ updateForm(formId: string, formBindingData: formBindingData.FormBindingData): Pr
| 错误码ID | 错误信息 |
| -------- | -------- |
| 401 |
If the input parameter is not valid parameter.
|
以上错误码的详细介绍请参见
[
卡片错误码
](
../errorcodes/errorcode-form.md
)
。
| 401 |
调用接口入参错误。
|
|以上错误码的详细介绍请参见
[
卡片错误码
](
../errorcodes/errorcode-form.md
)
。||
**示例:**
```
ts
import
formBindingData
from
'
@ohos.application.formBindingData
'
;
var
formId
=
"
12400633174999288
"
;
let
obj
=
formBindingData
.
createFormBindingData
({
temperature
:
"
22c
"
,
time
:
"
22:00
"
});
import
formProvider
from
'
@ohos.app.form.formProvider
'
;
let
formId
=
"
12400633174999288
"
;
let
obj
=
formBindingData
.
createFormBindingData
({
temperature
:
"
22c
"
,
time
:
"
22:00
"
});
try
{
formProvider
.
updateForm
(
formId
,
obj
).
then
(()
=>
{
console
.
log
(
'
formProvider updateForm success
'
);
console
.
log
(
`formProvider updateForm success`
);
}).
catch
((
error
)
=>
{
console
.
log
(
'
formProvider updateForm, error:
'
+
JSON
.
stringify
(
error
)
);
console
.
log
(
`promise error, code:
${
error
.
code
}
, message:
${
error
.
message
}
)`
);
});
}
catch
(
error
)
{
console
.
log
(
`catch err
->
${
JSON
.
stringify
(
error
)}
`
);
console
.
log
(
`catch err
or, code:
${
error
.
code
}
, message:
${
error
.
message
}
)
`
);
}
```
...
...
@@ -193,29 +201,31 @@ getFormsInfo(callback: AsyncCallback<Array<formInfo.FormInfo>>): voi
| 参数名 | 类型 | 必填 | 说明 |
| ------ | ------ | ---- | ------- |
| callback | AsyncCallback
<
Array
<
[FormInfo](js-apis-app-form-formInfo.md)
>>
| 是 | 回调函数。返回查询到的卡片信息。 |
| callback | AsyncCallback
<
Array
<
[
formInfo.
FormInfo](js-apis-app-form-formInfo.md)
>>
| 是 | 回调函数。返回查询到的卡片信息。 |
**错误码:**
| 错误码ID | 错误信息 |
| -------- | -------- |
| 401 |
If the input parameter is not valid parameter.
|
以上错误码的详细介绍请参见
[
卡片错误码
](
../errorcodes/errorcode-form.md
)
。
| 401 |
调用接口入参错误。
|
|以上错误码的详细介绍请参见
[
卡片错误码
](
../errorcodes/errorcode-form.md
)
。||
**示例:**
```
ts
import
formProvider
from
'
@ohos.app.form.formProvider
'
;
try
{
formProvider
.
getFormsInfo
((
error
,
data
)
=>
{
if
(
error
)
{
console
.
log
(
'
formProvider getFormsInfo, error:
'
+
JSON
.
stringify
(
error
)
);
console
.
log
(
`callback error, code:
${
error
.
code
}
, message:
${
error
.
message
}
)`
);
}
else
{
console
.
log
(
'
formProvider getFormsInfo, data:
'
+
JSON
.
stringify
(
data
));
console
.
log
(
'
formProvider getFormsInfo, data:
'
+
JSON
.
stringify
(
data
));
}
});
}
catch
(
error
)
{
console
.
log
(
`catch err->
${
JSON
.
stringify
(
error
)}
`
);
console
.
log
(
`catch error, code:
${
error
.
code
}
, message:
${
error
.
message
}
)
`
);
}
```
## getFormsInfo
...
...
@@ -231,33 +241,35 @@ getFormsInfo(filter: formInfo.FormInfoFilter, callback: AsyncCallback<Array&l
| 参数名 | 类型 | 必填 | 说明 |
| ------ | ------ | ---- | ------- |
| filter |
[
formInfo.FormInfoFilter
](
js-apis-app-form-formInfo.md#forminfofilter
)
| 是 | 卡片信息过滤器。 |
| callback | AsyncCallback
<
Array
<
[FormInfo](js-apis-app-form-formInfo.md)
>>
| 是 | 回调函数。返回查询到符合条件的卡片信息。 |
| callback | AsyncCallback
<
Array
<
[
formInfo.
FormInfo](js-apis-app-form-formInfo.md)
>>
| 是 | 回调函数。返回查询到符合条件的卡片信息。 |
**错误码:**
| 错误码ID | 错误信息 |
| -------- | -------- |
| 401 |
If the input parameter is not valid parameter.
|
以上错误码的详细介绍请参见
[
卡片错误码
](
../errorcodes/errorcode-form.md
)
。
| 401 |
调用接口入参错误。
|
|以上错误码的详细介绍请参见
[
卡片错误码
](
../errorcodes/errorcode-form.md
)
。||
**示例:**
```
ts
import
formInfo
from
'
@ohos.application.formInfo
'
;
const
filter
:
formInfo
.
FormInfoFilter
=
{
// get info of forms belong to module entry.
moduleName
:
"
entry
"
import
formInfo
from
'
@ohos.app.form.formInfo
'
;
import
formProvider
from
'
@ohos.app.form.formProvider
'
;
const
filter
:
formInfo
.
FormInfoFilter
=
{
// get info of forms belong to module entry.
moduleName
:
"
entry
"
};
try
{
formProvider
.
getFormsInfo
(
filter
,
(
error
,
data
)
=>
{
if
(
error
)
{
console
.
log
(
'
formProvider getFormsInfo, error:
'
+
JSON
.
stringify
(
error
)
);
console
.
log
(
`callback error, code:
${
error
.
code
}
, message:
${
error
.
message
}
)`
);
}
else
{
console
.
log
(
'
formProvider getFormsInfo, data:
'
+
JSON
.
stringify
(
data
));
console
.
log
(
'
formProvider getFormsInfo, data:
'
+
JSON
.
stringify
(
data
));
}
});
}
catch
(
error
)
{
console
.
log
(
`catch err
->
${
JSON
.
stringify
(
error
)}
`
);
}
catch
(
error
)
{
console
.
log
(
`catch err
or, code:
${
error
.
code
}
, message:
${
error
.
message
}
)
`
);
}
```
...
...
@@ -279,31 +291,33 @@ getFormsInfo(filter?: formInfo.FormInfoFilter): Promise<Array<formInfo.For
| 类型 | 说明 |
| :------------ | :---------------------------------- |
| Promise
<
Array
<
[FormInfo](js-apis-app-form-formInfo.md)
>>
| Promise对象。返回查询到符合条件的卡片信息。 |
| Promise
<
Array
<
[
formInfo.
FormInfo](js-apis-app-form-formInfo.md)
>>
| Promise对象。返回查询到符合条件的卡片信息。 |
**错误码:**
| 错误码ID | 错误信息 |
| -------- | -------- |
| 401 |
If the input parameter is not valid parameter.
|
以上错误码的详细介绍请参见
[
卡片错误码
](
../errorcodes/errorcode-form.md
)
。
| 401 |
调用接口入参错误。
|
|以上错误码的详细介绍请参见
[
卡片错误码
](
../errorcodes/errorcode-form.md
)
。||
**示例:**
```
ts
import
formInfo
from
'
@ohos.application.formInfo
'
;
const
filter
:
formInfo
.
FormInfoFilter
=
{
// get info of forms belong to module entry.
moduleName
:
"
entry
"
import
formInfo
from
'
@ohos.app.form.formInfo
'
;
import
formProvider
from
'
@ohos.app.form.formProvider
'
;
const
filter
:
formInfo
.
FormInfoFilter
=
{
// get info of forms belong to module entry.
moduleName
:
"
entry
"
};
try
{
formProvider
.
getFormsInfo
(
filter
).
then
((
data
)
=>
{
console
.
log
(
'
formProvider getFormsInfo, data:
'
+
JSON
.
stringify
(
data
));
}).
catch
((
error
)
=>
{
console
.
log
(
'
formProvider getFormsInfo, error:
'
+
JSON
.
stringify
(
error
)
);
console
.
log
(
`promise error, code:
${
error
.
code
}
, message:
${
error
.
message
}
)`
);
});
}
catch
(
error
)
{
console
.
log
(
`catch err
->
${
JSON
.
stringify
(
error
)}
`
);
console
.
log
(
`catch err
or, code:
${
error
.
code
}
, message:
${
error
.
message
}
)
`
);
}
```
...
...
@@ -322,21 +336,23 @@ requestPublishForm(want: Want, formBindingData: formBindingData.FormBindingData,
| 参数名 | 类型 | 必填 | 说明 |
| ------ | ---------------------------------------------------------------------- | ---- | ---------------- |
| want |
[
Want
](
js-apis-application-want.md
)
| 是 | 发布请求。需包含以下字段。
<br>
abilityName: 目标卡片ability
<br>
parameters:
<br>
"ohos.extra.param.key.form_dimension"
<br>
"ohos.extra.param.key.form_name"
<br>
"ohos.extra.param.key.module_name" |
| formBindingData
.FormBindingData |
[
FormBindingData
](
js-apis-app-form-formBindingData.md#formbindingdata
)
| 是 | 创建卡片的数据。 |
| formBindingData
|
[
formBindingData.
FormBindingData
](
js-apis-app-form-formBindingData.md#formbindingdata
)
| 是 | 创建卡片的数据。 |
| callback | AsyncCallback
<
string
>
| 是 | 回调函数。返回卡片标识。 |
**错误码:**
| 错误码ID | 错误信息 |
| -------- | -------- |
| 401 |
If the input parameter is not valid parameter.
|
以上错误码的详细介绍请参见
[
卡片错误码
](
../errorcodes/errorcode-form.md
)
。
| 401 |
调用接口入参错误。
|
|以上错误码的详细介绍请参见
[
卡片错误码
](
../errorcodes/errorcode-form.md
)
。||
**示例:**
```
ts
import
formBindingData
from
'
@ohos.application.formBindingData
'
;
var
want
=
{
import
formProvider
from
'
@ohos.app.form.formProvider
'
;
let
want
=
{
abilityName
:
"
FormAbility
"
,
parameters
:
{
"
ohos.extra.param.key.form_dimension
"
:
2
,
...
...
@@ -345,16 +361,16 @@ var want = {
}
};
try
{
let
obj
=
formBindingData
.
createFormBindingData
({
temperature
:
"
22c
"
,
time
:
"
22:00
"
});
let
obj
=
formBindingData
.
createFormBindingData
({
temperature
:
"
22c
"
,
time
:
"
22:00
"
});
formProvider
.
requestPublishForm
(
want
,
obj
,
(
error
,
data
)
=>
{
if
(
error
)
{
console
.
log
(
'
formProvider requestPublishForm, error:
'
+
JSON
.
stringify
(
error
)
);
console
.
log
(
`callback error, code:
${
error
.
code
}
, message:
${
error
.
message
}
)`
);
}
else
{
console
.
log
(
'
formProvider requestPublishForm, form ID is:
'
+
JSON
.
stringify
(
data
));
}
});
}
catch
(
error
)
{
console
.
log
(
`catch err
->
${
JSON
.
stringify
(
error
)}
`
);
console
.
log
(
`catch err
or, code:
${
error
.
code
}
, message:
${
error
.
message
}
)
`
);
}
```
...
...
@@ -379,13 +395,15 @@ requestPublishForm(want: Want, callback: AsyncCallback<string>): void
| 错误码ID | 错误信息 |
| -------- | -------- |
| 401 |
If the input parameter is not valid parameter.
|
以上错误码的详细介绍请参见
[
卡片错误码
](
../errorcodes/errorcode-form.md
)
。
| 401 |
调用接口入参错误。
|
|以上错误码的详细介绍请参见
[
卡片错误码
](
../errorcodes/errorcode-form.md
)
。||
**示例:**
```
ts
var
want
=
{
import
formProvider
from
'
@ohos.app.form.formProvider
'
;
let
want
=
{
abilityName
:
"
FormAbility
"
,
parameters
:
{
"
ohos.extra.param.key.form_dimension
"
:
2
,
...
...
@@ -396,15 +414,14 @@ var want = {
try
{
formProvider
.
requestPublishForm
(
want
,
(
error
,
data
)
=>
{
if
(
error
)
{
console
.
log
(
'
formProvider requestPublishForm, error:
'
+
JSON
.
stringify
(
error
)
);
console
.
log
(
`callback error, code:
${
error
.
code
}
, message:
${
error
.
message
}
)`
);
}
else
{
console
.
log
(
'
formProvider requestPublishForm, form ID is:
'
+
JSON
.
stringify
(
data
));
}
});
}
catch
(
error
)
{
console
.
log
(
`catch err
->
${
JSON
.
stringify
(
error
)}
`
);
console
.
log
(
`catch err
or, code:
${
error
.
code
}
, message:
${
error
.
message
}
)
`
);
}
```
## requestPublishForm
...
...
@@ -422,7 +439,7 @@ requestPublishForm(want: Want, formBindingData?: formBindingData.FormBindingData
| 参数名 | 类型 | 必填 | 说明 |
| --------------- | ------------------------------------------------------------ | ---- | ------------------------------------------------------------ |
| want |
[
Want
](
js-apis-application-want.md
)
| 是 | 发布请求。需包含以下字段。
<br>
abilityName: 目标卡片ability
<br>
parameters:
<br>
"ohos.extra.param.key.form_dimension"
<br>
"ohos.extra.param.key.form_name"
<br>
"ohos.extra.param.key.module_name" |
| formBindingData
.FormBindingData |
[
FormBindingData
](
js-apis-app-form-formBindingData.md#formbindingdata
)
| 否 | 创建卡片的数据。 |
| formBindingData
|
[
formBindingData.
FormBindingData
](
js-apis-app-form-formBindingData.md#formbindingdata
)
| 否 | 创建卡片的数据。 |
**返回值:**
...
...
@@ -434,13 +451,15 @@ requestPublishForm(want: Want, formBindingData?: formBindingData.FormBindingData
| 错误码ID | 错误信息 |
| -------- | -------- |
| 401 |
If the input parameter is not valid parameter.
|
以上错误码的详细介绍请参见
[
卡片错误码
](
../errorcodes/errorcode-form.md
)
。
| 401 |
调用接口入参错误。
|
|以上错误码的详细介绍请参见
[
卡片错误码
](
../errorcodes/errorcode-form.md
)
。||
**示例:**
```
ts
var
want
=
{
import
formProvider
from
'
@ohos.app.form.formProvider
'
;
let
want
=
{
abilityName
:
"
FormAbility
"
,
parameters
:
{
"
ohos.extra.param.key.form_dimension
"
:
2
,
...
...
@@ -452,10 +471,10 @@ try {
formProvider
.
requestPublishForm
(
want
).
then
((
data
)
=>
{
console
.
log
(
'
formProvider requestPublishForm success, form ID is :
'
+
JSON
.
stringify
(
data
));
}).
catch
((
error
)
=>
{
console
.
log
(
'
formProvider requestPublishForm, error:
'
+
JSON
.
stringify
(
error
)
);
console
.
log
(
`promise error, code:
${
error
.
code
}
, message:
${
error
.
message
}
)`
);
});
}
catch
(
error
)
{
console
.
log
(
`catch err
->
${
JSON
.
stringify
(
error
)}
`
);
console
.
log
(
`catch err
or, code:
${
error
.
code
}
, message:
${
error
.
message
}
)
`
);
}
```
...
...
@@ -478,37 +497,38 @@ isRequestPublishFormSupported(callback: AsyncCallback<boolean>): void
**示例:**
```
ts
import
formProvider
from
'
@ohos.app.form.formProvider
'
;
try
{
formProvider
.
isRequestPublishFormSupported
((
error
,
isSupported
)
=>
{
if
(
error
)
{
console
.
log
(
'
formProvider isRequestPublishFormSupported, error:
'
+
JSON
.
stringify
(
error
));
}
else
{
if
(
isSupported
)
{
var
want
=
{
abilityName
:
"
FormAbility
"
,
parameters
:
{
"
ohos.extra.param.key.form_dimension
"
:
2
,
"
ohos.extra.param.key.form_name
"
:
"
widget
"
,
"
ohos.extra.param.key.module_name
"
:
"
entry
"
}
};
try
{
formProvider
.
requestPublishForm
(
want
,
(
error
,
data
)
=>
{
if
(
error
)
{
console
.
log
(
'
formProvider requestPublishForm, error:
'
+
JSON
.
stringify
(
error
));
}
else
{
console
.
log
(
'
formProvider requestPublishForm, form ID is:
'
+
JSON
.
stringify
(
data
));
if
(
error
)
{
console
.
log
(
`callback error, code:
${
error
.
code
}
, message:
${
error
.
message
}
)`
);
}
else
{
if
(
isSupported
)
{
var
want
=
{
abilityName
:
"
FormAbility
"
,
parameters
:
{
"
ohos.extra.param.key.form_dimension
"
:
2
,
"
ohos.extra.param.key.form_name
"
:
"
widget
"
,
"
ohos.extra.param.key.module_name
"
:
"
entry
"
}
});
}
catch
(
error
)
{
console
.
log
(
`catch err->
${
JSON
.
stringify
(
error
)}
`
);
};
try
{
formProvider
.
requestPublishForm
(
want
,
(
error
,
data
)
=>
{
if
(
error
)
{
console
.
log
(
`callback error, code:
${
error
.
code
}
, message:
${
error
.
message
}
)`
);
}
else
{
console
.
log
(
'
formProvider requestPublishForm, form ID is:
'
+
JSON
.
stringify
(
data
));
}
});
}
catch
(
error
)
{
console
.
log
(
`catch error, code:
${
error
.
code
}
, message:
${
error
.
message
}
)`
);
}
}
}
}
});
});
}
catch
(
error
)
{
console
.
log
(
`catch err
->
${
JSON
.
stringify
(
error
)}
`
);
console
.
log
(
`catch err
or, code:
${
error
.
code
}
, message:
${
error
.
message
}
)
`
);
}
```
...
...
@@ -531,32 +551,33 @@ isRequestPublishFormSupported(): Promise<boolean>
**示例:**
```
ts
import
formProvider
from
'
@ohos.app.form.formProvider
'
;
try
{
formProvider
.
isRequestPublishFormSupported
().
then
((
isSupported
)
=>
{
if
(
isSupported
)
{
var
want
=
{
abilityName
:
"
FormAbility
"
,
parameters
:
{
"
ohos.extra.param.key.form_dimension
"
:
2
,
"
ohos.extra.param.key.form_name
"
:
"
widget
"
,
"
ohos.extra.param.key.module_name
"
:
"
entry
"
}
abilityName
:
"
FormAbility
"
,
parameters
:
{
"
ohos.extra.param.key.form_dimension
"
:
2
,
"
ohos.extra.param.key.form_name
"
:
"
widget
"
,
"
ohos.extra.param.key.module_name
"
:
"
entry
"
}
};
try
{
formProvider
.
requestPublishForm
(
want
).
then
((
data
)
=>
{
console
.
log
(
'
formProvider requestPublishForm success, form ID is :
'
+
JSON
.
stringify
(
data
));
}).
catch
((
error
)
=>
{
console
.
log
(
'
formProvider requestPublishForm, error:
'
+
JSON
.
stringify
(
error
)
);
console
.
log
(
`promise error, code:
${
error
.
code
}
, message:
${
error
.
message
}
)`
);
});
}
catch
(
error
)
{
console
.
log
(
`catch err
->
${
JSON
.
stringify
(
error
)}
`
);
console
.
log
(
`catch err
or, code:
${
error
.
code
}
, message:
${
error
.
message
}
)
`
);
}
}
}).
catch
((
error
)
=>
{
console
.
log
(
'
formProvider isRequestPublishFormSupported, error:
'
+
JSON
.
stringify
(
error
)
);
console
.
log
(
`promise error, code:
${
error
.
code
}
, message:
${
error
.
message
}
)`
);
});
}
catch
(
error
)
{
console
.
log
(
`catch err
->
${
JSON
.
stringify
(
error
)}
`
);
console
.
log
(
`catch err
or, code:
${
error
.
code
}
, message:
${
error
.
message
}
)
`
);
}
```
\ No newline at end of file
zh-cn/application-dev/reference/apis/js-apis-inner-application-formExtensionContext.md
浏览文件 @
7d07bb0f
# FormExtensionContext
FormExtensionContext模块是FormExtension的上下文环境,继承自ExtensionContext。
FormExtensionContext模块是FormExtension
Ability
的上下文环境,继承自ExtensionContext。
FormExtensionContext模块提供FormExtension具有的接口和能力。
FormExtensionContext模块提供FormExtension
Ability
具有的接口和能力。
> **说明:**
>
...
...
@@ -11,23 +11,24 @@ FormExtensionContext模块提供FormExtension具有的接口和能力。
## 使用说明
在使用FormExtensionContext的功能前,需要通过FormExtension获取。
在使用FormExtensionContext的功能前,需要通过FormExtension
Ability
获取。
```
ts
import
FormExtensionAbility
from
'
@ohos.app.form.FormExtensionAbility
'
;
import
formBindingData
from
'
@ohos.app.form.formBindingData
'
;
export
default
class
MyFormExtensionAbility
extends
FormExtensionAbility
{
onAddForm
(
)
{
let
formContext
=
this
.
context
;
// 获取FormExtensionContext
// ...
let
dataObj1
=
{
temperature
:
"
11c
"
,
"
time
"
:
"
11:00
"
};
let
obj1
=
formBindingData
.
createFormBindingData
(
dataObj1
);
return
obj1
;
}
}
onAddForm
(
want
)
{
let
formContext
=
this
.
context
;
// 获取FormExtensionContext
// ...
let
dataObj1
=
{
temperature
:
"
11c
"
,
"
time
"
:
"
11:00
"
};
let
obj1
=
formBindingData
.
createFormBindingData
(
dataObj1
);
return
obj1
;
}
}
;
```
## startAbility
...
...
@@ -50,23 +51,29 @@ startAbility(want: Want, callback: AsyncCallback<void>): void
**示例:**
```
ts
var
want
=
{
deviceId
:
""
,
bundleName
:
"
com.example.formstartability
"
,
abilityName
:
"
MainAbility
"
,
action
:
"
action1
"
,
entities
:
[
"
entity1
"
],
type
:
"
MIMETYPE
"
,
uri
:
"
key={true,true,false}
"
,
parameters
:
{}
}
this
.
context
.
startAbility
(
want
,
(
error
,
data
)
=>
{
if
(
error
)
{
console
.
log
(
'
FormExtensionContext startAbility, error:
'
+
JSON
.
stringify
(
error
));
}
else
{
console
.
log
(
`FormExtensionContext startAbility success`
);
}
})
import
FormExtensionAbility
from
'
@ohos.app.form.FormExtensionAbility
'
;
export
default
class
MyFormExtensionAbility
extends
FormExtensionAbility
{
onFormEvent
(
formId
,
message
)
{
// 当触发卡片message事件时,执行startAbility
console
.
log
(
'
FormExtensionAbility onFormEvent, formId:
'
+
formId
+
"
, message:
"
+
message
);
let
want
=
{
deviceId
:
""
,
bundleName
:
"
com.example.formstartability
"
,
abilityName
:
"
MainAbility
"
,
parameters
:
{
"
message
"
:
message
}
};
this
.
context
.
startAbility
(
want
,
(
error
,
data
)
=>
{
if
(
error
)
{
console
.
log
(
'
FormExtensionContext startAbility, error:
'
+
JSON
.
stringify
(
error
));
}
else
{
console
.
log
(
'
FormExtensionContext startAbility success
'
);
}
});
}
};
```
## startAbility
...
...
@@ -89,24 +96,30 @@ startAbility(want: Want): Promise<void>
| 类型 | 说明 |
| ------------ | ---------------------------------- |
| Promise
<
void
&
l
t;
| 无返回结果的Promise对象。 |
| Promise
<
void
&
g
t;
| 无返回结果的Promise对象。 |
**示例:**
```
ts
var
want
=
{
deviceId
:
""
,
bundleName
:
"
com.example.formstartability
"
,
abilityName
:
"
MainAbility
"
,
action
:
"
action1
"
,
entities
:
[
"
entity1
"
],
type
:
"
MIMETYPE
"
,
uri
:
"
key={true,true,false}
"
,
parameters
:
{}
}
this
.
context
.
startAbility
(
want
).
then
(()
=>
{
console
.
info
(
"
StartAbility Success
"
);
}).
catch
((
error
)
=>
{
console
.
info
(
"
StartAbility failed
"
);
});
import
FormExtensionAbility
from
'
@ohos.app.form.FormExtensionAbility
'
;
export
default
class
MyFormExtensionAbility
extends
FormExtensionAbility
{
onFormEvent
(
formId
,
message
)
{
// 当触发卡片message事件时,执行startAbility
console
.
log
(
'
FormExtensionAbility onFormEvent, formId:
'
+
formId
+
"
, message:
"
+
message
);
let
want
=
{
deviceId
:
""
,
bundleName
:
"
com.example.formstartability
"
,
abilityName
:
"
MainAbility
"
,
parameters
:
{
"
message
"
:
message
}
};
this
.
context
.
startAbility
(
want
).
then
(()
=>
{
console
.
info
(
"
StartAbility Success
"
);
}).
catch
((
error
)
=>
{
console
.
info
(
"
StartAbility failed
"
);
});
}
};
```
\ No newline at end of file
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录