harmony 鸿蒙@ohos.application.formBindingData (formBindingData)
@ohos.application.formBindingData (formBindingData)
The FormBindingData module provides APIs for widget data binding. You can use the APIs to create a FormBindingData object and obtain related information.
NOTE
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. This module is deprecated since API version 9. You are advised to use FormBindingData instead.
Modules to Import
import formBindingData from '@ohos.application.formBindingData';
FormBindingData
Describes a FormBindingData object.
System capability: SystemCapability.Ability.Form
Name | Type | Mandatory | Description |
---|---|---|---|
data | Object | Yes | Data to be displayed on the JS widget. The value can be an object containing multiple key-value pairs or a string in JSON format. |
createFormBindingData
createFormBindingData(obj?: Object|string): FormBindingData
Creates a FormBindingData object.
System capability: SystemCapability.Ability.Form
Parameters
Name | Type | Mandatory | Description |
---|---|---|---|
obj | Object|string | No | Data to be displayed on the JS widget. The value can be an object containing multiple key-value pairs or a string in JSON format. The image data is identified by ‘formImages’, and the content is multiple key-value pairs, each of which consists of an image identifier and image file descriptor. The final format is {‘formImages’: {‘key1’: fd1, ‘key2’: fd2}}. |
Return value
Type | Description |
---|---|
FormBindingData | FormBindingData object created based on the passed data. |
Example
import formBindingData from '@ohos.application.formBindingData';
import fs from '@ohos.file.fs';
import Base from '@ohos.base';
try {
let fd = fs.openSync('/path/to/form.png');
let createFormBindingDataParam = new Map<Object, string|object>();
let formImagesParam = new Map<Object, object>();
formImagesParam.set('image', fd);
createFormBindingDataParam.set("name", '21°');
createFormBindingDataParam.set('formImages', formImagesParam);
formBindingData.createFormBindingData(createFormBindingDataParam);
} catch (error) {
console.error(`catch error, error: ${JSON.stringify(error as Base.BusinessError)}`);
}
你可能感兴趣的鸿蒙文章
harmony 鸿蒙System Common Events (To Be Deprecated Soon)
harmony 鸿蒙System Common Events
harmony 鸿蒙API Reference Document Description
harmony 鸿蒙Enterprise Device Management Overview (for System Applications Only)
harmony 鸿蒙BundleStatusCallback
harmony 鸿蒙@ohos.bundle.innerBundleManager (innerBundleManager)
harmony 鸿蒙@ohos.distributedBundle (Distributed Bundle Management)
harmony 鸿蒙@ohos.bundle (Bundle)
harmony 鸿蒙@ohos.enterprise.EnterpriseAdminExtensionAbility (EnterpriseAdminExtensionAbility)
- 所属分类: 后端技术
- 本文标签:
热门推荐
-
2、 - 优质文章
-
3、 gate.io
-
8、 golang
-
9、 openharmony
-
10、 Vue中input框自动聚焦