当前位置:网站首页>[wechat applet] understand the basic composition of the applet project
[wechat applet] understand the basic composition of the applet project
2022-06-29 23:42:00 【Su Liang py】
Author's brief introduction : Su Liang ( Focus on web crawlers , Data analysis , On the way to learning the front end )
Blog home page : Su Liang .py The blog of
Series column : Basic course of applet development
Aphorisms : The sea is wide with fish , The sky is high and the birds are flying .
If you think the blogger's article is good , I hope you can support me for the third time in a row !!!
Follow the likes collection
List of articles
Daily recommendation
Recommend an artifact to everyone . Whether you are a student party or an office worker, you can use , The interview question bank is covered here , Brush questions online , Interviews with major manufacturers / Written test questions, etc . If you're still a student , The most important point is the simulated interview function , intelligence AI1v1 interview , Help you get to the big factory as soon as possible offer! Click the link to go directly to !=> Cattle from - Looking for work artifact
The project structure of the applet
1. Understand the basic composition and structure of the project
In the previous section, we talked about the registration of small programs and the downloading of development tools , After entering the applet development interface, it looks like this :
The most important one here is the resource manager .
- pages be used for The page where all applets are stored
- utils be used for Modules that store the nature of tools ( for example : Custom module for formatting time )
- app.js Applet project Entrance file
- app.json Applet project Global profile
- app.wxss Applet project Global style file
- project.config.json The configuration file for the project
- sitemap.json be used for Configure whether the applet and its page can be indexed by wechat
2. Part of the applet page
In small program development , We put all the applet pages in pages Directory , Exist as a separate folder , As shown in the figure :
Each of these pages consists of four basic files :
1 .js file ( Script file of the page , Store the data of the page , Event handling functions, etc )
2 .json file ( The configuration file of the current page , Configure the appearance of the window , Performance, etc. )
3 .wxml file ( Module structure file of the page )
4 .wxss file ( The style sheet file of the current page )
Finally, these four basic files form a page .
json The configuration file
json Role of profile
json It's a kind of data format , In actual development ,json Always in the form of a configuration file . Applet projects are no exception : Through different .json The configuration file , Applet projects can be configured at different levels .
In applet project json The configuration file has 4 Kind of :
- In the project root directory app.json The configuration file
- In the project root directory project.config.json The configuration file
- In the project root directory sitemap.json The configuration file
- In each page folder .json The configuration file
app.json The configuration file
app.json The current applet is Global configuration , Including the small program All page paths 、 Window appearance 、 Interface performance 、 Bottom tab etc. . In the project app.json The configuration is as follows :

pages: Used to record the path of all pages of the current applet window: Globally define the background color of all pages of the applet 、 Text color, etc style: Globally define the style version used by the applet component sitemapLocation: Used to indicate sitemap.json The location of
project.config.json The configuration file
project.config.json It's a project configuration file , Used to record our personalized configuration of applet development tools , for example :
setting The configuration related to compilation is saved in projectname The project name is saved in appid The account number of the applet is saved in the ID
among setting The settings of can be synchronized through local settings :
sitemap.json The configuration file
Wechat is now open Search in applet , The effect is similar to PC Web page SEO.sitemap.json File is used to configure the applet page Whether wechat indexing is allowed . When developers allow wechat indexing , Wechat will take the form of a crawler , Index the page content of the applet . When the user's search keyword matches the page successfully , The page of the applet will probably be displayed in the search results .
On the page .json The configuration file
Every page in the applet , have access to .json The document is right Configure the window appearance of this page , The configuration items in the page will overwrite app.json Of window The same configuration item in . for example :
See... For more color code details : A complete list of colors , Color code
New applet page
Create a new page , Only need app.json Of pages The storage path of the new page in , The applet developer tool can help us automatically create the corresponding page file , As shown in the figure :
Modify the project home page
Just adjust app.json -> pages The sequence of page paths in the array , You can modify the front page of the project . The applet will put the first page , Render as the first page of the project , As shown in the figure :
WXML Templates
What is? WXML?
WXML (WeiXin Markup Language) Is a set of tag language designed for small program framework , The structure used to build applet pages , Its function is similar to that in web page development HTML.
WXML And HTML The difference between
Different tag names
HTML ( div, span, img, a)
WXML ( view, text, image, navigator)Attribute nodes are different
eg:a and navigator In the tag href and url node
< a href=" " > Hyperlinks < /a >
< navigator url=" " >< /navigator >Similar to Vue Module syntax in
Data binding
The list of rendering
Conditions apply colours to a drawing
WXSS style
What is? WXSS?
WXSS(weiXin Style Sheets) It's a style language , Used to describe WXML Component style , Similar to... In web development CSS.
WXSS and CSS The difference between
Added rpx Unit of measure
CSS Pixel unit conversion needs to be carried out manually in , for example rem
WXSS Support new units of size at the bottom rpx, On screens of different sizes, the applet will automatically convertProvides global and local styles
In the project root directory app.WXSS Will work on all applet pages
Of partial pages .WXSS The style is only valid for the current pageWXSS Only partial CSS Selectors
.class and #id
element Element selector
Union selector 、 Descendant selector
::after and ::before Such as pseudo class selector
js Logical interaction
In the applet .js file
It is not enough for a project to only provide interface display , In the applet , We go through .js File to handle user operations . for example : Respond to user clicks 、 Get the user's location and so on .
Small program .js Classification of documents
In the applet .js Documents fall into three broad categories :
app.js file
It is the entry file of the whole applet project , By calling App() Function to start the entire applet
On the page .js file
Is the entry file of the page , By calling Page() Function to create and run the page
ordinary .js file
It is a common function module file , Used to encapsulate public functions or properties for use by pages
Here, I know the basic structure of the applet . Let's see you next time !
More question banks and summary of knowledge points , Interview skills => Cattle from , Come and brush the questions with me !
边栏推荐
- M1笔记本居家办公的痛点及解决方案 | 社区征文
- 设置安全组、域名备案、申请ssl证书
- Implementation principle of dynamic agent
- Node data collection and remote flooding transmission of label information
- SQL question brushing 595 Big country
- Constexpr function
- LC:最大子数组和
- Software testing interface testing JMeter 5.5 installation tutorial
- Become the only key
- LC: maximum subarray and
猜你喜欢

打造一个 API 快速开发平台,牛逼!

海外数字身份验证服务商ADVANCE.AI入选EqualOcean《2022品牌出海服务市场研究报告》

Gracefully transform the SMS business module and start the strategic mode!

6.28日刷题题解

Incluxdb time series database system

matlab习题 —— 程序控制流程练习

After working in the software development industry for six years, I changed my ideas in those years

剑指 Offer 15. 二进制中1的个数

Implementation of aut, a self-developed transport layer protocol for sound network -- dev for dev column

收藏!这些提高程序员生产力的工具你用过吗?
随机推荐
2022 PMP project management examination agile knowledge points (5)
提供有效的绩效评估
收藏!这些提高程序员生产力的工具你用过吗?
疫情下我离职一年,收入增长了10倍
海外数字身份验证服务商ADVANCE.AI入选EqualOcean《2022品牌出海服务市场研究报告》
Dépannage de l'étiquette: impossible d'ouvrir l'image marquée
Halcon实用:焊点检出设计思路
网上开户选哪个证券公司?还有,在线开户安全么?
6.28日刷题题解
Implementation principle of dynamic agent
Leetcode 1385. 两个数组间的距离值
How to solve the problem that the computer time is not automatically updated after proofreading
我想知道今天还可以开户么?另外想问,现在在线开户安全么?
動態代理的實現原理
剑指 Offer 14- I. 剪绳子
Solr basic operation
关于二叉树
Collection! Have you ever used these tools to improve programmer productivity?
Label Troubleshooting: unable to open the marked image
label問題排查:打不開標注好的圖像

