• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1# FormBindingData
2
3> ![icon-note.gif](public_sys-resources/icon-note.gif) **NOTE**
4> 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.
5
6## Modules to Import
7
8```
9import formBindingData from '@ohos.application.formBindingData';
10```
11
12## Required Permissions
13
14None
15
16## formBindingData.createFormBindingData
17
18createFormBindingData(obj?: Object | string): FormBindingData
19
20Creates a **FormBindingData** object.
21
22**System capability**: SystemCapability.Ability.Form
23
24**Parameters**
25
26| Name| Type          | Mandatory| Description                                                        |
27| ------ | -------------- | ---- | ------------------------------------------------------------ |
28| obj    | Object or string| No  | Data to be displayed on the JS service 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}}.|
29
30
31**Return value**
32
33| Type                               | Description                                   |
34| ----------------------------------- | --------------------------------------- |
35| [FormBindingData](#formbindingdata) | **FormBindingData** object created based on the passed data.|
36
37
38**Example**
39
40  ```js
41  let fd = fileio.openSync(path);
42  let obj = {
43      "temperature": "21°",
44      "formImages": {"image": fd}
45  };
46  let formBindingDataObj = formBindingData.createFormBindingData(obj);
47  ```
48
49## Attributes
50
51Describes a **FormBindingData** object.
52
53**System capability**: SystemCapability.Ability.Form
54
55| Name| Readable| Writable| Type| Mandatory| Description|
56| -------- | -------- | -------- | -------- | -------- | -------- |
57| data | Yes| No| Object | Yes| Data to be displayed on the JS service widget. The value can be an object containing multiple key-value pairs or a string in JSON format.|
58