当前位置:网站首页>[applet development] detailed explanation of host environment
[applet development] detailed explanation of host environment
2022-07-25 19:06:00 【Hua Weiyun】

Learning objectives of this section :
In depth understanding of the host environment composition of applets
@[toc]
1. The host environment of the applet
Mobile wechat is the host environment of small programs , Applets take advantage of the capabilities provided by the host environment , It can realize many functions that ordinary web pages cannot complete . for example : The applet calls the... Provided by wechat API Realize code scanning , Payment and other functions .
The content contained in the hosting environment of the applet :
- Communication model
- Operating mechanism
- Components
- API
2. Communication model
1. The subject of communication
The main body of communication in the applet is Render layer and Logic layer , among :
- WXML Templates and WXSS Styles work in the render layer
- JS Scripts work at the logical level
2. Communication model of applet
The communication model of the applet is divided into two parts :
- Render layer and Logic layer Communication between
- Logic layer and Third party servers Communication between
Both are forwarded through wechat clients
3. Operating mechanism
1. The startup process of the applet
- Download the code package of the applet to the local
- analysis app.json Global profile
- perform app.js Applet entry file , call App() Create an instance of the applet
- Rendering applet home page
- Applet startup completed

2. The process of page rendering
- Load the of the parsing page .json The configuration file
- To load a page .wxml Templates and .wxss style
- Execute the .js file , call Page() Create page instances
- Page rendering complete
4. Components
1. Classification of components in applet :
The components in the applet are also composed of Host environment Provided , Developers can quickly build a beautiful page structure based on components . Officials divide the components of small programs into 9 Categories: , Namely :
- View container
- Basic content </blue>
- Form components
- Navigation components
- Body assembly
- map Map components
- canvas Canvas components
- Opening ability
- Accessibility
2. Common view container class components
view
- Normal view area
- Be similar to HTML Medium div, Is a block level element
- Commonly used to achieve the layout effect of the page
for example : Use flex Achieve horizontal layout .
wxml Code :
<view class="container1"><view>A</view><view>B</view><view>C</view></view>wxss Code :
.container1 view{ width:100px; height:100px; text-align: center; line-height: 100px;}.container1 view:nth-child(1){ background-color: aquamarine;}.container1 view:nth-child(2){ background-color: azure;}.container1 view:nth-child(3){ background-color: darkorange;}.container1 { display: flex; justify-content: space-around;} Realization effect :
scroll-view
- Scrollable view area
- It is often used to achieve the effect of scrolling lists
utilize scroll-view Achieve the effect of scrolling up and down
wxml Code :
<scroll-view class="container1" scroll-y><view>A</view><view>B</view><view>C</view></scroll-view>Modified wxss Code :
.container1 { border:1px solid red; height:110px; /* Use scroll-view Set a fixed height */Realization effect :

swiper and swiper-item
- Carousel map container assembly and Shuffling figure item Components
Using these two components can achieve the effect of rotating pictures :
wxml Code :
<swiper class="swiper-container" indicator-dots="true" indicator-color="white" indicator-active-color="red" autoplay="true" interval="1000" circular><swiper-item><view class="item">A</view></swiper-item><swiper-item> <view class="item">B</view></swiper-item><swiper-item> <view class="item">C</view></swiper-item></swiper>wxss Code :
.swiper-container{ height:150px;}.item{ height:100%; line-height: 150px; text-align: center;}swiper-item:nth-child(1) .item{ background-color: aquamarine;}swiper-item:nth-child(2) .item{ background-color: azure;}swiper-item:nth-child(3) .item{ background-color: darkorange;} Realization effect :
3. Common basic content components
text
- Text component
- Be similar to HTML Medium span label , It's an in-line element
Long press the selected text content
<view> Long press to select the text content :<text user-select>HelloWorld!</text></view>
rich-text
- Rich text component
- Support HTML The string is rendered as WXML structure
hold HTML The string is rendered as the corresponding UI structure
<rich-text nodes="<h1 style='color:red'> title </h1>"> </rich-text>
4. Other common components
button
- Button components
- Functional ratio HTML Medium button Rich buttons
- adopt open-type Attribute can call various functions provided by wechat ( Customer service 、 forward 、 Get user authorization 、 Access to user information, etc )
image
- Picture components
- image The default width of the component is about 300px、 The height is about 240px
navigator
- Page navigation component
- Be similar to HTML Medium a link , Realize page Jump
5.API
In the applet API Is provided by the host environment , Through these rich applets API, Developers can easily call the capabilities provided by wechat , for example : Realize payment , Scan code and other functions .
Applet API Of 3 Big classification :
Event monitoring API
- characteristic : With on start , Used to monitor the trigger of some events
- give an example :wx.onWindowResize(function callback) Listen for window size changes
Sync API
- characteristic 1: With Sync At the end of the API It's all synchronous API
- characteristic 2: Sync API The results of the implementation of , You can get directly through the return value of the function , If the execution fails, an exception will be thrown
- give an example :wx.setStorageSync(‘key’, ‘value’) Write content to local storage
asynchronous API
- characteristic : Be similar to jQuery Medium $.ajax(options) function , Need to pass through success、fail、complete Receive the result of the call
- give an example :wx.request() Initiate a network data request , adopt success The callback function receives data
6. summary
In this section, we learned about the hosting environment of the applet and the specific contents of the hosting environment of the applet .
边栏推荐
- 【iniparser】项目配置工具iniparser的简单使用
- 2022 IAA industry category development insight series report - phase II
- Interface automation test platform fasterrunner series (IV) - continuous integration and solution of multi domain names
- Youfu network was invited to attend the 2022 national CIO conference and won the title of "CIO trusted brand"
- 蓝牙协议详解(蓝牙是什么)
- MySQL子查询篇(精选20道子查询练习题)
- Microsoft azure and Analysys jointly released the report "Enterprise Cloud native platform driven digital transformation"
- 接口自动化测试平台FasterRunner系列(四)- 持续集成、解决多域名
- 【919. 完全二叉树插入器】
- 这种动态规划你见过吗——状态机动态规划之股票问题(上)
猜你喜欢

基础乐理之音程的度数

高并发下如何保证数据库和缓存双写一致性?

SQL Server 2019 安装教程

There are several browser cores. How to upgrade if the browser version is too low

21 days proficient in typescript-4 - type inference and semantic check

Baklib: make excellent product instruction manual

基于FPGA的1080P 60Hz BT1120接口调试过程记录

In the first half of the year, the shipment volume has exceeded that of the whole year of last year, and centritec millimeter wave radar has "captured" the international giant

ThreadLocal夺命11连问

Ultimate doll 2.0 | cloud native delivery package
随机推荐
qt exec和show的区别
【小程序开发】你了解小程序开发吗?
Go code checking tool
Everyone can participate in the official launch of open source activities. We sincerely invite you to experience!
Software testing process (mind map)
Baklib:制作优秀的产品说明手册
Analysis of the internet jam in IM development? Network disconnection?
Single arm routing experiment demonstration (Huawei router device configuration)
jmeter性能测试实战视频(常用性能测试工具有哪些)
浅析IM即时通讯开发出现上网卡顿?网络掉线?
Virtual machine VMware installation steps (how to install software in virtual machine)
软件测试(思维导图)
In the first half of the year, the shipment volume has exceeded that of the whole year of last year, and centritec millimeter wave radar has "captured" the international giant
Interface automation test platform fasterrunner series (IV) - continuous integration and solution of multi domain names
MES管理系统有什么应用价值
Is Cinda securities a state-owned enterprise? Is it safe to open an account in Cinda securities?
PHP等于==和恒等于===的区别
Basic music theory -- configuring chords
srec_cat 常用参数的使用
21 days proficient in typescript-4 - type inference and semantic check