当前位置:网站首页>Small program introduction to proficient (2): understand the four important files of small program development
Small program introduction to proficient (2): understand the four important files of small program development
2020-11-06 20:37:00 【Tell me Zhan to hide】

1. The applet doesn't have DOM object , Everything is based on componentization
2. Four important files of the applet
- *.js —> view Logic —> javascript
- *.wxml —> view structure ----> html
- *.wxss —> view style -----> css
- *. json ----> view data -----> json file
Be careful : To facilitate developers to reduce configuration items , The four files that describe the page must have the same path and file name .
2.1 WXML
WXML(WeiXin Markup Language) Is the framework design of a set of tag language , combination Basic components 、 The event system , You can build the structure of the page .WXML It's like HTML Role
To fully understand WXML grammar , Please refer to WXML Syntax reference .
2.2 WXSS
WXSS (WeiXin Style Sheets) It's a style language , Used to describe WXML Component style .
WXSS Used to decide WXML How should components of .
In order to adapt to the vast number of front-end developers ,WXSS have CSS Most features . At the same time in order to more suitable for the development of WeChat applet ,WXSS Yes CSS It has been expanded and modified .
And CSS comparison ,WXSS The extended features are :
- Unit of measure
- Style import
2.3 json
JSON Is a data format , It's not a programming language , In the applet ,JSON Play the role of static configuration .
- Global configuration
In the applet root directory app.json The file is used for global configuration of wechat applets , Determine the path of the page file 、 Window representation 、 Set network timeout 、 More settings tab etc. .
- Configuration page
Each applet page can also use the same name .json File to configure the window representation of this page , Configuration items in the page will overwrite app.json Of window The same configuration item in .
- Tool configuration project.config.json
Usually when you use a tool , They will make some personalized configurations according to their preferences , For example, interface color 、 Compile configuration, etc , When you change to another computer and re install the tools , You have to reconfigure .
With that in mind , The applet developer tool generates a project.config.json, Any configuration you make on the tool will be written to this file , When you re install tools or change your computer to work , You just load the code package of the same project , Developer tools automatically
Be careful :
JSON The documents are all wrapped in braces {}, adopt key-value How to express data .JSON Of Key Must be wrapped in a double quotation mark , In practice , To write JSON When , Forget to give Key It's a common mistake to use double quotes for values or single quotes for double quotes .
JSON The value of can only be in the following data formats , Any other format will trigger an error , for example JavaScript Medium undefined.
- Numbers , Contains floating-point numbers and integers
- character string , Need to wrap in double quotes
- Bool value ,true perhaps false
- Array , Need to be wrapped in square brackets []
- object , Need to wrap in braces {}
- Null
The other thing to note is that JSON Cannot use comment in file , An attempt to add a comment will result in an error .
2.4 js
It's not enough for a service to only display the interface , You also need to interact with users : Respond to user clicks 、 Get the user's location and so on . In the applet , We just wrote JS Script files to handle user actions .
- Registration page
For each page in the applet , All need to be mapped on the page js Register in the file , Specify the initial data for the page 、 Lifecycle Callback 、 Event handling functions, etc
- Use Page Constructor registration page
Simple pages can be used Page() Construct .
- Use Component The constructor constructs the page
Page The constructor works for simple pages . But for complex pages , Page Constructors may not work well .
here , have access to Component Constructors to construct pages . Component The main difference between constructors is : Methods need to be placed in methods: { } Inside .
版权声明
本文为[Tell me Zhan to hide]所创,转载请带上原文链接,感谢
边栏推荐
- Tron smart wallet PHP development kit [zero TRX collection]
- nacos、ribbon和feign的簡明教程
- 大道至简 html + js 实现最朴实的小游戏俄罗斯方块
- EOS founder BM: what's the difference between UE, UBI and URI?
- Humor: hacker programming is actually similar to machine learning!
- 大会倒计时|2020 PostgreSQL亚洲大会-中文分论坛议程安排
- Kubernetes and OAM to build a unified, standardized application management platform knowledge! (Internet disk link attached)
- 华为云微认证考试简介
- Cglib 如何实现多重代理?
- The difference between gbdt and XGB, and the mathematical derivation of gradient descent method and Newton method
猜你喜欢

文件过多时ls命令为什么会卡住?

The legality of IPFs / filecoin: protecting personal privacy from disclosure

消息队列(MessageQueue)-分析

一部完整的游戏,需要制作哪些音乐?

For a while, a dynamic thread pool was created, and the source code was put into GitHub

Read the advantages of Wi Fi 6 over Wi Fi 5 in 3 minutes

StickEngine-架构12-通信协议

What is the purchasing supplier system? Solution of purchasing supplier management platform

一路踩坑,被迫聊聊 C# 代码调试技巧和远程调试
![PHP application docking justswap special development kit【 JustSwap.PHP ]](/img/3b/00bc81122d330c9d59909994e61027.jpg)
PHP application docking justswap special development kit【 JustSwap.PHP ]
随机推荐
检测证书过期脚本
The method of realizing high SLO on large scale kubernetes cluster
C + + and C + + programmers are about to be eliminated from the market
小游戏云开发入门
Asp.Net Core learning notes: Introduction
What are the common problems of DTU connection
(2) ASP.NET Core3.1 Ocelot routing
2020年数据库技术大会助力技术提升
Try to build my mall from scratch (2): use JWT to protect our information security and perfect swagger configuration
Uncle Bob: the software architecture is similar to a house. Object oriented is the structure of the house, and the water pipe is functional programming
嘉宾专访|2020 PostgreSQL亚洲大会阿里云数据库专场:曾文旌
StickEngine-架构12-通信协议
大数据处理黑科技:揭秘PB级数仓GaussDB(DWS) 并行计算技术
Individual annual work summary and 2019 work plan (Internet)
視覺滾動[反差美]
Flink的DataSource三部曲之一:直接API
常用SQL语句总结
What are Devops
Gather in Beijing! The countdown to openi 2020
Even liver three all night, jvm77 high frequency interview questions detailed analysis, this?