当前位置:网站首页>Introduction to applet
Introduction to applet
2022-06-12 09:25:00 【Xiao Wei wants to learn from all the guys】
Preface :
This article introduces the applet , And the technology stack that needs to be used to make small programs , There is also a small case , Interested friends can try to do it .
If there is anything that needs to be improved, please don't hesitate to give me advice
Thank you all for your support 
List of articles
Introduction to applet
Applets are a new open capability , Developers can quickly develop a small program . Small programs can be easily obtained and spread in wechat , At the same time, it has an excellent use experience .
The main advantage
- Users can easily access services , No need to install or download to use
- It has richer functions and excellent use experience
- Ability to encapsulate a range of interfaces , Help with rapid development and iteration
- It doesn't take up memory , No need to download
- Less advertising , It is conducive to a good user experience
Common technology stacks for developing small programs
JavaScript: JavaScript( abbreviation “JS”) It is a kind of lightweight with function priority , Interpreted or just in time compiled programming languages . Although it was developed as Web It's famous for its scripting language , But it's also used in many non browser environments ,JavaScript Based on prototype programming 、 Multi paradigm dynamic scripting language , And support object-oriented 、 imperative 、 declarative 、 Functional programming paradigm .
Wechat applet JavaScript The operating environment is not Browser Neither Node.js. It runs on wechat App In the context of , Can't operate Browser context Under the DOM, It can't pass Node.js Related interfaces access the operating system API. therefore , Strictly speaking , Wechat applets are not Html5, Although the development process and the technology stack used Html5 It is interlinked. .
WXML: The full name is WeiXin Markup Language, yes ⼩ Program framework design ⼀ Set of tags ⾔, combination ⼩ The basic components of the program 、 The event system , You can build pages ⾯ Structure .
As the display layer of wechat applet , It's not using Html, It was invented on the basis of XML The description of grammar .
WXSS: The style used to decorate the presentation layer .WXSS(WeiXin Style Sheets) yes MINA The design of the ⼀ Pattern language ⾔,⽤ In describing WXML Component style .
WXSS⽤ To decide WXML How to display the components of ⽰. In order to adapt ⼴⼤ Front end developers , our WXSS have CSS⼤ Some characteristics . At the same time, in order to be more suitable for the development of wechat ⼩ Program , We are right. CSS Into the ⾏ Expanded and modified . And css phase ⽐ Our extended features are : ruler ⼨ Guide to units and styles ⼊.

Modules commonly used by applets
WXML. Wechat signs ⾔,⽤ Yu Zhan ⽰UI Templates , similar HTML,⽂ The suffix of the piece is “.wxml”.
WXSS. full name WeiXin Style Sheets,⽤ It is stipulated that UI style , have CSS ⼤ Some characteristics . stay CSS The ruler is extended on the basis of ⼨ Unit and style guide ⼊.⽂ The suffix of the piece is “.wxss”
WXS. full name WeiXin Script. After the encapsulation JS,⼀ Generally embedded in WXML page ⾯, very ⽅ Build the page ⾯, The label is ”《wxs》 《/wxs》".
JS. ordinary JavaScript, often ⽤ To control the entire page ⾯ The logic of . Suffix named “.js”
JSON.⽤ Yu Xiang ⽬ Global configuration or single page ⾯ To configure , Suffix named “.json”.

Applet case ( Part of the code )
Effect demonstration :
If you need all the code, you can talk to the blogger privately
Part of the code :
JS:
import request from "../../lib/request";
const app = getApp();
import serviceData from '../../data/config';
Page({
data : {
products:[],
currentPage:1,
perPage : 5
},
onLoad(option){
var categoryId = option.id;
var pageData = new Object();
pageData.page = this.data.currentPage;
pageData.per_page = this.data.perPage;
//request({path:'/categories/' + categoryId + '/products', data: pageData})
//.then(({data:products}) => this.setData({products}));
this.setData({
products: serviceData.categoryData});
/*wx.setNavigationBarTitle({ title: option.title, success: function(res) { // success } })*/
},
navigateToProduct(event) {
var productId = event.currentTarget.dataset.goodsId;
wx.navigateTo({
url: '../products/products?id=' + productId
});
},
lower : function(option){
var categoryId = option.id;
console.log('lower more products data');
wx.showNavigationBarLoading();
var that = this;
setTimeout(()=>{
wx.hideNavigationBarLoading();
var nextPageData = new Object();
nextPageData.per_page = this.data.perPage;
nextPageData.page = this.data.currentPage +1;
var products = serviceData.categoryData;
this.setData({
currentPage:++this.data.currentPage});
this.setData({
products:this.data.products.concat(products)});//concat Splice together
}, 1000);
},
});
JSON
{
"backgroundTextStyle":"light",
"navigationBarBackgroundColor": "#000",
"navigationBarTitleText": " Fresh fruit ",
"navigationBarTextStyle":"white"
}
WXML
<scroll-view class="product-list" bindscrolltolower="lower" scroll-y="true" style="height:100%" scroll-into-view="{
{toView}}" upper-threshold="10">
<view class="product-group">
<view class="product" wx:for="{
{products}}" wx:for-item="product" data-goods-id="{
{product.id}}" bindtap="navigateToProduct">
<view><image mode="scaleToFill" src="{
{product.covers_image}}"></image></view>
<view class="product-content product-name"><text>{
{product.goods_name}}</text></view>
<view class="product-content product-price"><text>¥ {
{product.goods_price}}</text>
<text class="product-market">¥ {
{product.market_price}}</text>
</view>
</view>
</view>
</scroll-view>
WXSS
.product-list{
background-color: white;
box-sizing: border-box;
padding: 2rpx;
}
.product-group{
margin: 5rpx;
padding:2rpx;
display: block;
overflow: hidden;
}
.product{
width:350rpx;
border: 1px solid #e2e2e2;
float: left;
margin: 6rpx;
}
.product image {
height: 300rpx;
width: 100%;
}
.product-name {
height: 60rpx;
padding-bottom: 5rpx;
border-bottom: 1px solid #efefef;
font-size: 25rpx;
white-space: nowrap;
text-overflow: ellipsis;
}
.product-content {
margin: 15rpx;
overflow: hidden;
}
.product-price {
margin-top: 15rpx;
color: red;
margin-bottom: 15rpx;
font-size: 28rpx;
font-weight: 1rpx;
}
.product-market {
margin:10rpx;
color: darkgray;
font-size: 24rpx;
font-weight: 1rpx;
text-decoration:line-through;
}
This is the end of the article , You can try it if you like , If there is anything inappropriate or needs to be improved Welcome to communicate with us
Finally, I wish you all a happy June day, ha ha ha 
Xiao Wei once again thanks all his friends for their support 
边栏推荐
- Selenium面试题分享
- anxious
- 软件测试报告中常见的疏漏,给自己提个醒
- Résoudre le problème de demander à l'élément d'être ouvert lorsque l'unit é est ouverte et que vous n'avez pas été ouvert auparavant (peut - être fermé anormalement auparavant)
- 解决當打開Unity時 提示項目已經打開,而自己之前並沒有打開過(可能之前异常關閉)的問題
- After receiving the picture, caigou was very happy and played with PDF. The submission format was flag{xxx}, and the decryption characters should be in lowercase
- Solve the problem that when unity is opened, you will be prompted that the project has been opened, but you have not opened it before (it may be closed abnormally before)
- TAP 系列文章3 | Tanzu Application Platform 部署参考架构介绍
- Top command meaning
- Exists usage in SQL
猜你喜欢
How should the test plan be written? A thought teaches you

Description of string
ADB命令集锦,一起来学吧

Filters and listeners

Visualization of two-dimensional feature logistic regression prediction results
Selection of interview questions for software testing
软件测试需求分析方法有哪些,一起来看看吧

卖疯了的临期产品:超低价、大混战与新希望

Distributed task scheduling
软件测试报告中常见的疏漏,给自己提个醒
随机推荐
On absolute value function in C language
RecyclerView的onBindViewHolder被同时调用两次解决方法
2026年中国软件定义存储市场容量将接近45.1亿美元
90%以上软件公司都会问的软件测试面试题赶紧来背吧
Microservice gateway
Autojs微信研究:微信不同的版本或模拟器上的微信里的控件ip是不同的。
ThreadLocal
Black screen solution for computer boot
解决当打开Unity时 提示项目已经打开,而自己之前并没有打开过(可能之前异常关闭)的问题
There must be something you want to know about software testing experience sharing
ABC253F Operations on a Matrix
UEFI EDKII 编程学习
MySQL安装
5种最常见的CEPH失败方案
Complete knapsack problem 1
Autojs学习笔记6:text(txt).findOne()切换app时会报错,最后解决实现效果,切换任何app直到脚本找到指定的txt文字的控件进行点击。
2022 极术通讯-安谋科技纷争尘埃落定,本土半导体产业基石更稳
测试用例和bug描述规范参考
Financial test interview questions to help you get the offer
软件测试基础知识分享,写点你不知道的