1e41f4b71Sopenharmony_ci# System Applications
2e41f4b71Sopenharmony_ci
3e41f4b71Sopenharmony_ci
4e41f4b71Sopenharmony_ci
5e41f4b71Sopenharmony_ci
6e41f4b71Sopenharmony_ci## Utils
7e41f4b71Sopenharmony_ci
8e41f4b71Sopenharmony_ci
9e41f4b71Sopenharmony_ci### Failed to Run a KV Store on LiteOS-A (Hi3516 or Hi3518)
10e41f4b71Sopenharmony_ci
11e41f4b71Sopenharmony_ci**Symptom**
12e41f4b71Sopenharmony_ci
13e41f4b71Sopenharmony_ciWhen the LiteOS-A kernel (Hi3516 or Hi3518) directly calls the API provided by the KV store, the compiled executable program fails to run.
14e41f4b71Sopenharmony_ci
15e41f4b71Sopenharmony_ci**Possible Causes**
16e41f4b71Sopenharmony_ci
17e41f4b71Sopenharmony_ciThe compiled executable program is run directly without being converted to an application using **AbilityKit** APIs. In this case, the Bundle Manager Service (BMS) cannot correctly set the path for storing application data during application installation. As a result, the KV store fails to run.
18e41f4b71Sopenharmony_ci
19e41f4b71Sopenharmony_ci**Solution**
20e41f4b71Sopenharmony_ci
21e41f4b71Sopenharmony_ciCall the **UtilsSetEnv** function of the KV store to set the data storage path.
22e41f4b71Sopenharmony_ci
23e41f4b71Sopenharmony_ci
24e41f4b71Sopenharmony_ci```
25e41f4b71Sopenharmony_ciUtilsSetEnv("/storage/com.example.kv");
26e41f4b71Sopenharmony_ci```
27e41f4b71Sopenharmony_ci
28e41f4b71Sopenharmony_ci
29e41f4b71Sopenharmony_ci## Visual Application
30e41f4b71Sopenharmony_ci
31e41f4b71Sopenharmony_ci
32e41f4b71Sopenharmony_ci### Is there a global variable that can be accessed by all pages?
33e41f4b71Sopenharmony_ci
34e41f4b71Sopenharmony_ciThere is no such a global variable.
35e41f4b71Sopenharmony_ci
36e41f4b71Sopenharmony_ci
37e41f4b71Sopenharmony_ci### How do I obtain DOM elements?
38e41f4b71Sopenharmony_ci
39e41f4b71Sopenharmony_ciYou can obtain DOM elements via the **ref** attribute. You can use methods of the obtained elements but cannot change their attributes. The sample code is as follows:
40e41f4b71Sopenharmony_ci
41e41f4b71Sopenharmony_ci
42e41f4b71Sopenharmony_ci```
43e41f4b71Sopenharmony_ci
44e41f4b71Sopenharmony_ci
45e41f4b71Sopenharmony_ci   
46e41f4b71Sopenharmony_ci   
47e41f4b71Sopenharmony_ci
48e41f4b71Sopenharmony_ci
49e41f4b71Sopenharmony_ci/* index.js */
50e41f4b71Sopenharmony_ciexport default {
51e41f4b71Sopenharmony_ci    data: {
52e41f4b71Sopenharmony_ci        images:[
53e41f4b71Sopenharmony_ci            {src:"common/frame1.png"},
54e41f4b71Sopenharmony_ci            {src:"common/frame2.png"},
55e41f4b71Sopenharmony_ci            {src:"common/frame3.png"}
56e41f4b71Sopenharmony_ci        ]
57e41f4b71Sopenharmony_ci    },
58e41f4b71Sopenharmony_ci    handleClick(){
59e41f4b71Sopenharmony_ci        // Obtain the component through the $refs attribute. (The ref attribute of the component has been set to animator in the HML file.)
60e41f4b71Sopenharmony_ci        const animator = this.$refs.animator;
61e41f4b71Sopenharmony_ci        const state = animator.getState();
62e41f4b71Sopenharmony_ci        if(state == "paused"){
63e41f4b71Sopenharmony_ci            animator.resume();
64e41f4b71Sopenharmony_ci        }else if(state == "stopped"){
65e41f4b71Sopenharmony_ci            animator.start();
66e41f4b71Sopenharmony_ci        }else{
67e41f4b71Sopenharmony_ci            animator.pause();
68e41f4b71Sopenharmony_ci        }
69e41f4b71Sopenharmony_ci    }
70e41f4b71Sopenharmony_ci}
71e41f4b71Sopenharmony_ci```
72e41f4b71Sopenharmony_ci
73e41f4b71Sopenharmony_ci
74e41f4b71Sopenharmony_ci### How do I pass values between pages?
75e41f4b71Sopenharmony_ci
76e41f4b71Sopenharmony_ciYou can pass values through **params** of the **router.replace** method. The sample code is as follows:
77e41f4b71Sopenharmony_ci
78e41f4b71Sopenharmony_ciSet **params** to the values to be passed on a page. The sample code is as follows:
79e41f4b71Sopenharmony_ci
80e41f4b71Sopenharmony_ci
81e41f4b71Sopenharmony_ci```
82e41f4b71Sopenharmony_cirouter.replace({
83e41f4b71Sopenharmony_ci    uri:'pages/detail/detail',  // URI of the page to be redirected to.
84e41f4b71Sopenharmony_ci    params:{transferData:this.data}  // Data to be transferred. You need to define the data amount and name.
85e41f4b71Sopenharmony_ci});
86e41f4b71Sopenharmony_ci```
87e41f4b71Sopenharmony_ci
88e41f4b71Sopenharmony_ciReceive the passed values on another page.
89e41f4b71Sopenharmony_ci
90e41f4b71Sopenharmony_ci
91e41f4b71Sopenharmony_ci```
92e41f4b71Sopenharmony_cionInit(){
93e41f4b71Sopenharmony_ci    const data = this.transferData;  // Use the onInit function to receive the passed data.
94e41f4b71Sopenharmony_ci}  
95e41f4b71Sopenharmony_ci```
96e41f4b71Sopenharmony_ci
97e41f4b71Sopenharmony_ci
98e41f4b71Sopenharmony_ci### How do I scroll a list to an item?
99e41f4b71Sopenharmony_ci
100e41f4b71Sopenharmony_ciCall the **scrollTo** method of the list. The input parameter of this method is the index of the target item. You can specify an item index, or obtain the index through the **scrollend** event.
101e41f4b71Sopenharmony_ci
102e41f4b71Sopenharmony_ci
103e41f4b71Sopenharmony_ci### Does the <text> component support multiple lines?
104e41f4b71Sopenharmony_ci
105e41f4b71Sopenharmony_ciYes. The **<text>** component supports multiple lines. You can use the **Enter** key to start a new line. If you do not set the height attribute of the text, the component automatically starts a new line based on the content.
106e41f4b71Sopenharmony_ci
107e41f4b71Sopenharmony_ci
108e41f4b71Sopenharmony_ci### Why is a component not displayed?
109e41f4b71Sopenharmony_ci
110e41f4b71Sopenharmony_ci**Symptom**
111e41f4b71Sopenharmony_ci
112e41f4b71Sopenharmony_ciThe component added to the **.hml** file cannot be displayed.
113e41f4b71Sopenharmony_ci
114e41f4b71Sopenharmony_ci**Possible Causes**
115e41f4b71Sopenharmony_ci
116e41f4b71Sopenharmony_ci- The width and height of the component may not be set.
117e41f4b71Sopenharmony_ci
118e41f4b71Sopenharmony_ci- The style setting may be incorrect.
119e41f4b71Sopenharmony_ci
120e41f4b71Sopenharmony_ci**Solution**
121e41f4b71Sopenharmony_ci
122e41f4b71Sopenharmony_ci1. Check whether the width and height values are set explicitly.
123e41f4b71Sopenharmony_ci
124e41f4b71Sopenharmony_ci2. Check whether the style of the component is set correctly.
125e41f4b71Sopenharmony_ci
126e41f4b71Sopenharmony_ci
127e41f4b71Sopenharmony_ci
128e41f4b71Sopenharmony_ci### How do I implement scrolling on a page?
129e41f4b71Sopenharmony_ci
130e41f4b71Sopenharmony_ciThere are three ways to implement page scrolling: **scroll**, **<list>**, or **<swiper>**. For a root component with **scroll** set, the scrolling effect is automatically implemented when the component size exceeds the screen size. For details, see the development specifications.
131e41f4b71Sopenharmony_ci
132e41f4b71Sopenharmony_ci
133e41f4b71Sopenharmony_ci### Why do not the left and top attributes take effect?
134e41f4b71Sopenharmony_ci
135e41f4b71Sopenharmony_ciThe **left** and **top** attributes must work with the **<stack>** component, except those of the root component.
136e41f4b71Sopenharmony_ci
137e41f4b71Sopenharmony_ci
138e41f4b71Sopenharmony_ci### Why does not dynamic binding take effect?
139e41f4b71Sopenharmony_ci
140e41f4b71Sopenharmony_ciThe object or its attributes are not defined before dynamic binding.
141e41f4b71Sopenharmony_ci
142e41f4b71Sopenharmony_ci
143e41f4b71Sopenharmony_ci### How do I implement relative and absolute positioning?
144e41f4b71Sopenharmony_ci
145e41f4b71Sopenharmony_ciYou can use the **<div\>** and **<stack\>** (with **top** and **left** attributes) components to implement relative positioning and absolute positioning.
146e41f4b71Sopenharmony_ci
147e41f4b71Sopenharmony_ci
148e41f4b71Sopenharmony_ci### How do I display or hide a component?
149e41f4b71Sopenharmony_ci
150e41f4b71Sopenharmony_ciYou can use **display**, **show**, or **if** to display or hide a component. When an **if** clause evaluates to **false**, the corresponding component will be removed from the VDOM. When **show** is set to **false**, the component will be invisible during rendering, but will not be removed from the VDOM.
151e41f4b71Sopenharmony_ci
152e41f4b71Sopenharmony_ci
153e41f4b71Sopenharmony_ci### What are the precautions for using the Margin attribute?
154e41f4b71Sopenharmony_ci
155e41f4b71Sopenharmony_ciThe **margin** attribute cannot be set for child components of the **<stack>** component.
156e41f4b71Sopenharmony_ci
157e41f4b71Sopenharmony_ci
158e41f4b71Sopenharmony_ci### What are the precautions for event subscription?
159e41f4b71Sopenharmony_ci
160e41f4b71Sopenharmony_ciOnly one page exists when the application is running. Therefore, the **router.replace** function destroys the previous page and then creates a new one. For pages involving event subscription, an event should be subscribed every time a page is created, and unsubscribed before page switching.
161e41f4b71Sopenharmony_ci
162e41f4b71Sopenharmony_ci
163e41f4b71Sopenharmony_ci### What are the precautions for using dynamic binding?
164e41f4b71Sopenharmony_ci
165e41f4b71Sopenharmony_ciDo not use too many dynamic bindings because they consume too much memory.
166e41f4b71Sopenharmony_ci
167e41f4b71Sopenharmony_ci
168e41f4b71Sopenharmony_ci### How does the loop attribute take effect for <swiper>?
169e41f4b71Sopenharmony_ci
170e41f4b71Sopenharmony_ciIf the total length of child components, except for the first and last ones, is greater than the length of **<swiper>**, the **loop** attribute takes effect.
171e41f4b71Sopenharmony_ci
172e41f4b71Sopenharmony_ci
173e41f4b71Sopenharmony_ci### What are the precautions for using an array?
174e41f4b71Sopenharmony_ci
175e41f4b71Sopenharmony_ciDo not include too many elements in an array. Avoid frequent operations on a large array.
176e41f4b71Sopenharmony_ci
177e41f4b71Sopenharmony_ci
178e41f4b71Sopenharmony_ci## hdc
179e41f4b71Sopenharmony_ci
180e41f4b71Sopenharmony_ci
181e41f4b71Sopenharmony_ci### hdc_std Failed to Connect to a Device
182e41f4b71Sopenharmony_ci
183e41f4b71Sopenharmony_ci- **Symptom**
184e41f4b71Sopenharmony_ci  
185e41f4b71Sopenharmony_ci  After the **hdc_std list targets** command is executed, **[Empty]** is displayed.
186e41f4b71Sopenharmony_ci
187e41f4b71Sopenharmony_ci- **Solution**
188e41f4b71Sopenharmony_ci  
189e41f4b71Sopenharmony_ci  1. The device cannot be identified.
190e41f4b71Sopenharmony_ci      
191e41f4b71Sopenharmony_ci      Check whether **HDC Device** exists under the **Universal Serial Bus controllers** in the **Device Manager**. If **HDC Device** does not exist, the device cannot be connected. In this case, disconnect and then reconnect the USB connection between the test PC and the OpenHarmony device, or burn the latest image.
192e41f4b71Sopenharmony_ci      
193e41f4b71Sopenharmony_ci  2. hdc_std works improperly.
194e41f4b71Sopenharmony_ci      Run the **hdc kill** command to terminate the hdc_std process or run the **hdc start -r** command to restart the hdc service. Then, run the **hdc list targets** command to check whether device information can be obtained.
195e41f4b71Sopenharmony_ci  
196e41f4b71Sopenharmony_ci  3. hdc_std does not match the device.
197e41f4b71Sopenharmony_ci      If the latest image is burnt on the device, the latest hdc_std version must be used.
198e41f4b71Sopenharmony_ci
199e41f4b71Sopenharmony_ci
200e41f4b71Sopenharmony_ci### hdc_std Failed to Run
201e41f4b71Sopenharmony_ci
202e41f4b71Sopenharmony_ci- **Symptom**
203e41f4b71Sopenharmony_ci  
204e41f4b71Sopenharmony_ci
205e41f4b71Sopenharmony_ci  After you click **hdc_std.exe**, the file fails to execute.
206e41f4b71Sopenharmony_ci
207e41f4b71Sopenharmony_ci- **Solution**
208e41f4b71Sopenharmony_ci  
209e41f4b71Sopenharmony_ci  **hdc_std.exe** requires no installation. You can use it after placing it to a local directory or adding the tool path to environment variables. Run the **cmd** command and then run the **hdc_std** command to start the tool.
210