提交 9f482e2f 编写于 作者: W wusongqing

fixed 58bcd256 from https://gitee.com/wusongqing/docs/pulls/4806

updated formhost and formprovider
Signed-off-by: Nwusongqing <wusongqing@huawei.com>
上级 208220d2
# FormHost # FormHost
> ![icon-note.gif](public_sys-resources/icon-note.gif) **NOTE**<br/> > **NOTE**<br/>
> The initial APIs of this module are supported since API version 8. Newly added APIs will be marked with a superscript to indicate their earliest API version. > The initial APIs of this module are supported since API version 8. Newly added APIs will be marked with a superscript to indicate their earliest API version.
Provides APIs related to the widget host. Provides APIs related to the widget host.
......
# FormProvider # FormProvider
> ![icon-note.gif](public_sys-resources/icon-note.gif) **NOTE** > **NOTE**<br>
> The initial APIs of this module are supported since API version 8. Newly added APIs will be marked with a superscript to indicate their earliest API version. > The initial APIs of this module are supported since API version 8. Newly added APIs will be marked with a superscript to indicate their earliest API version.
Provides APIs related to the widget provider. Provides APIs related to the widget provider.
...@@ -38,8 +38,8 @@ SystemCapability.Ability.Form ...@@ -38,8 +38,8 @@ SystemCapability.Ability.Form
```js ```js
var formId = "12400633174999288"; var formId = "12400633174999288";
formProvider.setFormNextRefreshTime(formId, 5, (error, data) => { formProvider.setFormNextRefreshTime(formId, 5, (error, data) => {
if (error) { if (error.code) {
console.log('formProvider setFormNextRefreshTime, error:' + error.code); console.log('formProvider setFormNextRefreshTime, error:' + JSON.stringify(error));
} }
}); });
``` ```
...@@ -71,7 +71,9 @@ SystemCapability.Ability.Form ...@@ -71,7 +71,9 @@ SystemCapability.Ability.Form
```js ```js
var formId = "12400633174999288"; var formId = "12400633174999288";
formProvider.setFormNextRefreshTime(formId, 5).catch((error) => { formProvider.setFormNextRefreshTime(formId, 5).then(() => {
console.log('formProvider setFormNextRefreshTime success');
}).catch((error) => {
console.log('formProvider setFormNextRefreshTime, error:' + JSON.stringify(error)); console.log('formProvider setFormNextRefreshTime, error:' + JSON.stringify(error));
}); });
``` ```
...@@ -101,8 +103,8 @@ SystemCapability.Ability.Form ...@@ -101,8 +103,8 @@ SystemCapability.Ability.Form
var formId = "12400633174999288"; var formId = "12400633174999288";
let obj = formBindingData.createFormBindingData({temperature:"22c", time:"22:00"}); let obj = formBindingData.createFormBindingData({temperature:"22c", time:"22:00"});
formProvider.updateForm(formId, obj, (error, data) => { formProvider.updateForm(formId, obj, (error, data) => {
if (error) { if (error.code) {
console.log('formProvider updateForm, error:' + error.code); console.log('formProvider updateForm, error:' + JSON.stringify(error));
} }
}); });
``` ```
...@@ -136,7 +138,9 @@ SystemCapability.Ability.Form ...@@ -136,7 +138,9 @@ SystemCapability.Ability.Form
import formBindingData from '@ohos.application.formBindingData'; import formBindingData from '@ohos.application.formBindingData';
var formId = "12400633174999288"; var formId = "12400633174999288";
let obj = formBindingData.createFormBindingData({temperature:"22c", time:"22:00"}); let obj = formBindingData.createFormBindingData({temperature:"22c", time:"22:00"});
formProvider.updateForm(formId, obj).catch((error) => { formProvider.updateForm(formId, obj).then(() => {
console.log('formProvider updateForm success');
}).catch((error) => {
console.log('formProvider updateForm, error:' + JSON.stringify(error)); console.log('formProvider updateForm, error:' + JSON.stringify(error));
}); });
``` ```
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册