当前位置:网站首页>[wechat applet] view container and basic content components
[wechat applet] view container and basic content components
2022-07-01 06:32:00 【Front end Xiao Liu is not afraid of cattle】
Developers can quickly build a page structure by using components , Components are also introduced in the previous chapter , So this article Niuniu will take you to learn the components of small programs .
We can understand components as tags embedded in wechat , Its role in the applet is similar to HTML The label is consistent , However, the functions of components are more diverse 、 Specifically .
This matter should not be delayed , Let's go !

List of articles
One , View container class components
1.1 view
Normal view container , In the wechat applet ,
viewEquivalent toHTMLMediumdivlabel , Belongs to block level elementsviewBecause of its meaninglessness , It is often used to make the layout of the general framework of small programs
chestnuts :
The vertical layout is realized as follows wxml file
<view class="column">
<view class="view-1 box"></view>
<view class="view-2 box"></view>
<view class="view-3 box"></view>
</view>
wxss file
.column{
margin: 0 auto;
width: 100px;
}
.view-1{
background-color: lightblue;
}
.view-2{
background-color: lightcoral;
}
.view-3{
background-color: lightgreen;
}
.box{
width: 100px;
height: 100px;
}
view There are no default styles for components , It is very suitable for use as a layout structure , Such as grid layout ,flex Layout and so on .
effect :
1.2 srcoll-view
- Relative to
view,scroll-viewMore scrollable functions ,scroll-view This is called a scrollable view area - It is generally used to realize the list scrolling function of small programs
- Common properties :
scroll-x, Allow horizontal scrollingscroll-y, Allow vertical scrollingbindscrolltoupperScroll to top / Left triggerbindscrolltolowerScroll to the bottom / Right trigger
bindscrolltoupper and bindscrolltolower Generally, it is used together with event binding , Events are the communication between the rendering layer and the logic layer , User generated behavior on the render layer , The logic layer responds to this behavior .
chestnuts :wxml file
<scroll-view class="scroll" scroll-y>
<view class="box view-1"></view>
<view class="box view-2"></view>
<view class="box view-3"></view>
</scroll-view>
wxss file
.scroll{
width: 100px;
height: 120px;
}
.box{
width: 100px;
height: 100px;
}
.view-1{
background-color: lightgreen;
}
.view-2{
background-color: lightpink;
}
.view-3{
background-color: lightskyblue;
}
effect :
Of course you can scroll-y Attribute to scroll-x, Roll horizontally
1.3 swiper and swiper-item
swiper, Slider view container , You can set the elements for sliding playback , It should be noted that , Can only be placed insideswiper-itemlabel , Otherwise, it will lead to undefined behavior .swiper-item, It can only be placed inswiper, Be careful , Its width and height are automatically set to100%.- It is generally used to set the rotation chart
- Common properties :
indicator-dotsSet whether to use the panel to indicate points , The default isfalseindicator-colorColor of panel indication points , The default value isrgba(0,0,0,.3)indicator-colorThe currently selected indicator color , The default value is#000autoplayWhether to automatically switch pictures , The default isfalseintervalTime interval of automatic switching , The default is5000mscircularWhether to select connection sliding ,== That is, when you slide to the last picture , Is it allowed to move the next one back to the first one , The default value isfalse
Rotation map chestnut :wxml file
<swiper class="container" indicator-dots="true" autoplay="true" circular="true" >
<swiper-item class="box item-1">
<view></view>
</swiper-item>
<swiper-item class="box item-2">
<view></view>
</swiper-item>
<swiper-item class="box item-3">
<view></view>
</swiper-item>
</swiper>
wxss file
.container{
height: 200px;
}
.box{
height: 100%;
}
.item-1{
background-color: lightgreen;
}
.item-2{
background-color: lightpink;
}
.item-3{
background-color: lightgray;
}
That's it , We realized the rotation map , Compared to using... On the web JS Complex operation of , This low code implementation is not very comfortable , In order to improve efficiency , Low code will also be the trend in the future
effect :
The view container component also has drag and drop views movable-area, Pop up view page-container, If you are interested, you can learn something about
Two , Basic content components
2.1 text
- The content description is the host text , Is a text component , You can think of it as an applet
spanlabel , becausetextIt's also an in-line element . - Common properties :
user-select, Is text optional , If you can copy , Be careful : This attribute enables the text component to be displayed asinline-block
2.2 rich-text
- The content description is rich text , We can go through
nodesattribute , hold HTML Render the string to the corresponding UI structure
As shown below :
<rich-text nodes="<h1 style='color: lightblue'> title </h1>"></rich-text>
The effect is as follows :
This is the end of the article , The next preview is to explain the form components and make a small case , If you think the article is useful to you, you can pay attention to Niuniu's subsequent updates , Thank you for your support !
Debt see ~
边栏推荐
- C#如何打印輸出原版數組
- Camouflage request header Library: Anti useragent
- Chapter V input / output (i/o) management
- 异常检测方法梳理,看这篇就够了!
- 启牛学堂合作的证券公司是哪家?开户安全吗?
- HCM Beginner (II) - information type
- FPGA - 7 Series FPGA internal structure clocking-01-clock Architecture Overview
- [unity shader amplify shader editor (ASE) Chapter 9]
- Self confidence is indispensable for technology
- sci-hub如何使用
猜你喜欢
随机推荐
10 golang operator
RestTemplate使用
Lxml module (data extraction)
sql中TCL语句(事务控制语句)
SystemVerilog learning-07-class inheritance and package use
网络爬虫
Detailed steps for installing redis on Windows system
浅谈SIEM
DML statement in SQL (data operation language)
ManageEngine Zhuohao helps you comply with ISO 20000 standard (IV)
码力十足学量化|如何在财务报告寻找合适的财务公告
[leetcode] day91- duplicate elements exist
C language course is provided with employee information management system (large operation)
手把手教你实现一个深度学习框架...
Draw a directed graph based on input
Promise
如果我在广州,到哪里开户比较好?究竟网上开户是否安全么?
软件工程复习
json模块
数据库对象:视图学习记录








