1# System Applications 2 3 4 5 6## Utils 7 8 9### Failed to Run a KV Store on LiteOS-A (Hi3516 or Hi3518) 10 11**Symptom** 12 13When the LiteOS-A kernel (Hi3516 or Hi3518) directly calls the API provided by the KV store, the compiled executable program fails to run. 14 15**Possible Causes** 16 17The 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. 18 19**Solution** 20 21Call the **UtilsSetEnv** function of the KV store to set the data storage path. 22 23 24``` 25UtilsSetEnv("/storage/com.example.kv"); 26``` 27 28 29## Visual Application 30 31 32### Is there a global variable that can be accessed by all pages? 33 34There is no such a global variable. 35 36 37### How do I obtain DOM elements? 38 39You 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: 40 41 42``` 43 44 45 46 47 48 49/* index.js */ 50export default { 51 data: { 52 images:[ 53 {src:"common/frame1.png"}, 54 {src:"common/frame2.png"}, 55 {src:"common/frame3.png"} 56 ] 57 }, 58 handleClick(){ 59 // Obtain the component through the $refs attribute. (The ref attribute of the component has been set to animator in the HML file.) 60 const animator = this.$refs.animator; 61 const state = animator.getState(); 62 if(state == "paused"){ 63 animator.resume(); 64 }else if(state == "stopped"){ 65 animator.start(); 66 }else{ 67 animator.pause(); 68 } 69 } 70} 71``` 72 73 74### How do I pass values between pages? 75 76You can pass values through **params** of the **router.replace** method. The sample code is as follows: 77 78Set **params** to the values to be passed on a page. The sample code is as follows: 79 80 81``` 82router.replace({ 83 uri:'pages/detail/detail', // URI of the page to be redirected to. 84 params:{transferData:this.data} // Data to be transferred. You need to define the data amount and name. 85}); 86``` 87 88Receive the passed values on another page. 89 90 91``` 92onInit(){ 93 const data = this.transferData; // Use the onInit function to receive the passed data. 94} 95``` 96 97 98### How do I scroll a list to an item? 99 100Call 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. 101 102 103### Does the <text> component support multiple lines? 104 105Yes. 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. 106 107 108### Why is a component not displayed? 109 110**Symptom** 111 112The component added to the **.hml** file cannot be displayed. 113 114**Possible Causes** 115 116- The width and height of the component may not be set. 117 118- The style setting may be incorrect. 119 120**Solution** 121 1221. Check whether the width and height values are set explicitly. 123 1242. Check whether the style of the component is set correctly. 125 126 127 128### How do I implement scrolling on a page? 129 130There 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. 131 132 133### Why do not the left and top attributes take effect? 134 135The **left** and **top** attributes must work with the **<stack>** component, except those of the root component. 136 137 138### Why does not dynamic binding take effect? 139 140The object or its attributes are not defined before dynamic binding. 141 142 143### How do I implement relative and absolute positioning? 144 145You can use the **<div\>** and **<stack\>** (with **top** and **left** attributes) components to implement relative positioning and absolute positioning. 146 147 148### How do I display or hide a component? 149 150You 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. 151 152 153### What are the precautions for using the Margin attribute? 154 155The **margin** attribute cannot be set for child components of the **<stack>** component. 156 157 158### What are the precautions for event subscription? 159 160Only 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. 161 162 163### What are the precautions for using dynamic binding? 164 165Do not use too many dynamic bindings because they consume too much memory. 166 167 168### How does the loop attribute take effect for <swiper>? 169 170If 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. 171 172 173### What are the precautions for using an array? 174 175Do not include too many elements in an array. Avoid frequent operations on a large array. 176 177 178## hdc 179 180 181### hdc_std Failed to Connect to a Device 182 183- **Symptom** 184 185 After the **hdc_std list targets** command is executed, **[Empty]** is displayed. 186 187- **Solution** 188 189 1. The device cannot be identified. 190 191 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. 192 193 2. hdc_std works improperly. 194 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. 195 196 3. hdc_std does not match the device. 197 If the latest image is burnt on the device, the latest hdc_std version must be used. 198 199 200### hdc_std Failed to Run 201 202- **Symptom** 203 204 205 After you click **hdc_std.exe**, the file fails to execute. 206 207- **Solution** 208 209 **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