当前位置:网站首页>[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 ~
边栏推荐
- 做技术,自信不可或缺
- TCL statements in SQL (transaction control statements)
- 绕圆旋转动画组件,拿过来直接用
- Find the original array for the inverse logarithm
- [ManageEngine] terminal management system helps Huasheng securities' digital transformation
- How does the port scanning tool help enterprises?
- Idea easy to use plug-in summary!!!
- 2022 年江苏省职业院校技能大赛(中职) 网络搭建与应用赛项公开赛卷
- 网络爬虫
- SQL语言的学习记录一
猜你喜欢

【Unity Shader 消融效果_案例分享】

SQL学习笔记九种连接2

mysql学习

图片服务器项目测试
![[unity shader amplify shader editor (ASE) Chapter 9]](/img/f5/f0f6786406e149187e71c8e12cde0d.png)
[unity shader amplify shader editor (ASE) Chapter 9]

软件工程复习

sci-hub如何使用

Lxml module (data extraction)
![[ManageEngine] how to realize network automatic operation and maintenance](/img/8a/75332d3180f92c6a6482d881032bbf.png)
[ManageEngine] how to realize network automatic operation and maintenance

C language course is provided with employee information management system (large operation)
随机推荐
High order binary balanced tree
VS2019如何永久配置本地OpenCV4.5.5使用
根据输入画有向图
[summary of knowledge points] chi square distribution, t distribution, F distribution
HCM Beginner (II) - information type
[unity shader ablation effect _ case sharing]
How did ManageEngine Zhuohao achieve the goal of being selected into Gartner Magic Quadrant for four consecutive years?
H5网页判断是否安装了某个APP,安装则跳转未安装则下载的方案总结
B-树系列
Promise
ManageEngine Zhuohao helps you comply with ISO 20000 standard (IV)
idea 好用插件汇总!!!
关于变量是否线程安全的问题
SQL中DML语句(数据操作语言)
下载外文期刊的方法
C language course set up student elective course system (big homework)
Self confidence is indispensable for technology
HCM Beginner (III) - quickly enter pa70 and pa71 to browse employee information PA10
如果我在广州,到哪里开户比较好?究竟网上开户是否安全么?
微信公众号内嵌跳转微信小程序方案总结