diff --git a/zh-cn/application-dev/reference/apis/js-apis-formprovider.md b/zh-cn/application-dev/reference/apis/js-apis-formprovider.md index 08ca66d24c8157816ec6effba9d89345b111eefe..d54b0a645854978c69f51f0f880bfb2df10fd048 100644 --- a/zh-cn/application-dev/reference/apis/js-apis-formprovider.md +++ b/zh-cn/application-dev/reference/apis/js-apis-formprovider.md @@ -231,4 +231,117 @@ formProvider.getFormsInfo(filter).then((data) => { }).catch((error) => { console.log('formProvider getFormsInfo, error:' + JSON.stringify(error)); }); -``` \ No newline at end of file +``` + +## requestPublishForm9+ + +requestPublishForm(want: Want, formBindingData: formBindingData.FormBindingData, callback: AsyncCallback<string>): <void>; + +请求发布一张卡片到使用方。 + +**系统能力:** + +SystemCapability.Ability.Form + +**参数:** + +| 参数名 | 类型 | 必填 | 说明 | +| ------ | ---------------------------------------------------------------------- | ---- | ---------------- | +| want | [Want](js-apis-application-Want.md) | 是 | abilityName: 目标卡片ability
parameters:
"ohos.extra.param.key.form_dimension"
"ohos.extra.param.key.form_name"
"ohos.extra.param.key.module_name" | +| formBindingData | [FormBindingData](js-apis-formbindingdata.md#formbindingdata) | 是 | 用于创建卡片的数据 | +| callback | AsyncCallback<string> | 是 | callback形式返回卡片标识 | + +**示例:** + + ```js + import formBindingData from '@ohos.application.formBindingData'; + 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" + } + }; + let obj = formBindingData.createFormBindingData({temperature:"22c", time:"22:00"}); + formProvider.requestPublishForm(want, obj, (error, data) => { + if (error.code) { + console.log('formProvider requestPublishForm, error: ' + JSON.stringify(error)); + } else { + console.log('formProvider requestPublishForm, form ID is: ' + JSON.stringify(data)); + } + }); + ``` + +## requestPublishForm9+ + +requestPublishForm(want: Want, callback: AsyncCallback<string>): <void>; + +请求发布一张卡片到使用方。 + +**系统能力:** + +SystemCapability.Ability.Form + +**参数:** + +| 参数名 | 类型 | 必填 | 说明 | +| -------- | ----------------------------------- | ---- | ------------------------------------------------------------ | +| want | [Want](js-apis-application-Want.md) | 是 | abilityName: 目标卡片ability
parameters:
"ohos.extra.param.key.form_dimension"
"ohos.extra.param.key.form_name"
"ohos.extra.param.key.module_name" | +| callback | AsyncCallback<string> | 是 | callback形式返回卡片标识 | + +**示例:** + + ```js + 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" + } + }; + formProvider.requestPublishForm(want, (error, data) => { + if (error.code) { + console.log('formProvider requestPublishForm, error: ' + JSON.stringify(error)); + } else { + console.log('formProvider requestPublishForm, form ID is: ' + JSON.stringify(data)); + } + }); + ``` + +## requestPublishForm9+ + +requestPublishForm(want: Want, formBindingData?: formBindingData.FormBindingData): Promise<string>; + +请求发布一张卡片到使用方。 + +**系统能力:** + +SystemCapability.Ability.Form + +**参数:** + +| 参数名 | 类型 | 必填 | 说明 | +| --------------- | ------------------------------------------------------------ | ---- | ------------------------------------------------------------ | +| want | [Want](js-apis-application-Want.md) | 是 | abilityName: 目标卡片ability
parameters:
"ohos.extra.param.key.form_dimension"
"ohos.extra.param.key.form_name"
"ohos.extra.param.key.module_name" | +| formBindingData | [FormBindingData](js-apis-formbindingdata.md#formbindingdata) | 否 | 用于创建卡片的数据 | +| callback | AsyncCallback<string> | 是 | callback形式返回卡片标识 | + +**示例:** + + ```js + 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" + } + }; + 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)); + }); + ```