目录

File Organization

Directory Structure

The following figure shows the typical directory structure of the JavaScript module (entry/src/main/js/module) for an application with feature abilities (FA) using JavaScript APIs.

Figure 1 Directory structure

Figure 2 Directory structure for multiple instances resource sharing

Functions of the files are as follows:

Functions of the folders are as follows:

  • The i18n and resources folders cannot be renamed.

  • If the same resource name and directory are used under the share directory and the instance (default) directory, the resource in the instance directory will be used when you reference the directory.

  • The share directory does not support i18n.

  • You should create the optional folders (shown in the directory structure) as needed after you create the project in DevEco Studio.

File Access Rules

Application resources can be accessed via an absolute or relative path. An absolute path starts with a slash (/), and a relative path starts with ./ or ../. The rules are as follows:

When code file A needs to reference code file B:

  • If code files A and B are in the same directory, you can use either a relative or absolute path in code file B to reference resource files.

  • If code files A and B are in different directories, you must use an absolute path in code file B to reference resource files. The reason is that the directory of code file B changes during Webpack packaging.

  • Use an absolute path if you want to dynamically change the resource file path through data binding in a .js file.

Media File Formats

Table 1 Supported image formats

Format File Type
BMP .bmp
GIF .gif
JPEG .jpg
PNG .png
WebP .webp

Table 2 Supported video formats

Format File Type
H.264 AVC .3gp
Baseline Profile (BP) .mp4