WeChat Mini Program Development - Directory Structure
To learn a framework, you should first understand its directory structure. The directory structure of the applet is as follows:
It can be seen from the demo that it is mainly divided into two parts: the main part of the program and the business logic part.
1. The main part of the program: it consists of three files, which must be placed in the root directory of the project.
document |
Required |
effect |
app.js |
Yes | The applet logic, when the app starts, some methods in the file will be executed first. |
app.json |
Yes | Mini program public settings, system configuration of the entire app |
app.wxss |
no | The public style sheet of the applet can be understood as base.css in the front end |
2. Business logic part: For different projects, according to their specific business logic performance, the files have different organization methods, but the structure of the basic elements (pages) remains unchanged.
pages: store different business logic pages, here is the index folder (main page), logs folder (log page)
utils: store utility functions, and export formatTime through module.exports for other files to call
file type |
Required |
effect |
js |
Yes | Page logic, can be understood as controller, mainly to deal with business logic |
wxml |
Yes | The page structure can be understood as the view layer HTML |
wxss |
no | Page styles, which can be understood as CSS files |
json | no | page configuration, the current page configuration file |
Note: In order to facilitate developers to reduce configuration items, we stipulate that the four files of the description page must have the same path and file name.