1# Rules for Accessing Application Code Files 2 3 4The application code files can be accessed in the following ways: 5 6 7- Use a relative path to reference the code file. Specifically, use **../** to refer to the upper-level directory and **./** to refer to the current directory. 8 9- Use the root path of the current module to reference the code file, for example, **common/utils/utils**. 10 11## Example 12 13``` 14import { FoodData, FoodList } from "../common/utils/utils"; 15 16@Entry 17@Component 18struct FoodCategoryList { 19 private foodItems: FoodData[] = [ 20 new FoodData("Tomato"), 21 new FoodData("Strawberry"), 22 new FoodData("Cucumber") 23 ] 24 build() { 25 Column() { 26 FoodList({ foodItems: this.foodItems }) 27 } 28 } 29} 30``` 31 32Imported **utils.ets** file: 33 34```ts 35//common/utils/utils.ets 36 37export class FoodData { 38 name: string; 39 constructor(name: string) { 40 this.name = name; 41 } 42} 43 44@Component 45export struct FoodList { 46 private foodItems: FoodData[] 47 48 build() { 49 Column() { 50 Flex({justifyContent: FlexAlign.Center, alignItems: ItemAlign.Center}) { 51 Text('Food List') 52 .fontSize(20) 53 } 54 .width(200) 55 .height(56) 56 .backgroundColor('#FFf1f3f5') 57 List() { 58 ForEach(this.foodItems, item => { 59 ListItem() { 60 Text(item.name) 61 .fontSize(14) 62 } 63 }, item => item.toString()) 64 } 65 } 66 } 67} 68``` 69