当前位置:网站首页>小程序常用组件小结
小程序常用组件小结
2022-07-01 05:21:00 【前端小白在前进】
常用的视图容器类组件
view
- 类似与HTML中的
div,是一个块级元素- 常用来实现页面的布局效果
- 普通视图区域
scroll-view
- 可滚动的视图区域
常用来实现滚动列表效果
<scroll-view class="container1" scroll-y>
<view>A</view>
<view>B</view>
<view>C</view>
</scroll-view>
.container1 {
/* display: flex; justify-content: space-around; */
border: 1px solid #ccc;
width: 100px;
height: 120px;
}
.container1 view {
width: 100px;
height: 100px;
line-height: 100px;
text-align: center;
}
.container1 view:nth-child(1) {
background-color: lightgreen;
}
.container1 view:nth-child(2) {
background-color: blue;
}
.container1 view:nth-child(3) {
background-color: pink;
}
实现效果如下:
swiper和swiper-item
轮播图容器组件和轮播图item组件

<swiper class="swiper_container" indicator-dots indicator-color="#fff" indicator-active-color="gray" autoplay="true" interval="2000" 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>
.swiper_container {
height: 150px;
}
.item {
height: 100%;
line-height: 150px;
text-align: center;
}
swiper-item:nth-child(1) .item {
background-color: green;
}
swiper-item:nth-child(2) .item {
background-color: rgb(68, 227, 248);
}
swiper-item:nth-child(3) .item {
background-color: rgb(233, 35, 134);
}
效果如下:
常用的其他组件
button
- 按钮组件
- 功能比HTML中的button按钮丰富
- 通过open-type属性可以调用微信提供的各种功能(客服、转发、获取用户授权、获取用户信息等)
简单demo:
<rich-text nodes="<h1 style='color:red'>标题</h1>"></rich-text>
<view>~~~~~~~~通过type指定按钮类型~~~~~~~~</view>
<button>普通的按钮</button>
<button type="primary">主色调按钮</button>
<button type="warn">警告按钮</button>
<view>~~~~~~~通过size="mini"小尺寸按钮~~~~~~~</view>
<button size="mini">普通的按钮</button>
<button type="primary" size="mini">主色调按钮</button>
<button type="warn" size="mini">警告按钮</button>
<view>~~~~~~~plain镂空按钮~~~~~~~</view>
<button size="mini" plain>普通的按钮</button>
<button type="primary" size="mini" plain>主色调按钮</button>
<button type="warn" size="mini" plain>警告按钮</button>

image
- 图片组件
- image组件默认宽度为
300px、高度为240px

navigator(待补充)
- 页面导航组件
- 类似于HTML中的a链接
text
文本组件,相当于html中的
span标签,它的一个属性selectable可以实现长按选中的效果
rich-text
这个文本组件中具有一个属性:
nodes,nodes中可以写一些视图标签,并且可以直接写一些样式
<rich-text nodes="<h1 style='color:red'>标题</h1>"></rich-text>

边栏推荐
- el-cascader回显失败;el-cascader回显不出来
- Distributed - summary list
- Global and Chinese markets of superconductor 2022-2028: Research Report on technology, participants, trends, market size and share
- Print stream and system setout();
- Global and Chinese market of enterprise wireless LAN 2022-2028: Research Report on technology, participants, trends, market size and share
- [summer daily question] Luogu p5886 Hello, 2020!
- 3D建模與處理軟件簡介 劉利剛 中國科技大學
- [daily question in summer] letter delivery by p1629 postman in Luogu (to be continued...)
- CockroachDB 分布式事务源码分析之 TxnCoordSender
- 0xc000007b应用程序无法正常启动解决方案(亲测有效)
猜你喜欢

LRU cache for leveldb source code analysis

Ebpf cilium practice (2) - underlying network observability

Single page application

Cockroachdb: the resistant geo distributed SQL database paper reading notes

Unity drags and modifies scene camera parameters under the editor

Lock free concurrency of JUC (leguan lock)

複制寶貝提示材質不能為空,如何解决?

提高企业产品交付效率系列(1)—— 企业应用一键安装和升级

How to traverse massive data in redis

Data consistency between redis and database
随机推荐
Distributed transactions - Solutions
Implementation of distributed lock
Lock free concurrency of JUC (leguan lock)
Application of industrial conductive slip ring
液压滑环的特点讲解
Set集合详细讲解
Distributed - summary list
Use of STM32 expansion board temperature sensor and temperature humidity sensor
Software intelligence: the "world" and "boundary" of AI sentient beings in AAAs system
[Yugong series] February 2022 Net architecture class 005 ABP vNext Net core web application getting started configuration
CockroachDB 分布式事务源码分析之 TxnCoordSender
Go learning notes (5) basic types and declarations (4)
Youqitong [vip] v3.7.2022.0106 official January 22 Edition
Detailed explanation of distributed global unique ID solution
QDataStream的简单读写验证
如何开始学剪辑?零基础详细解析
Global and Chinese market for instant messaging security and compliance solutions 2022-2028: Research Report on technology, participants, trends, market size and share
Daily question -leetcode1175- permutation of prime numbers - Mathematics
JS random verification code
Leetcode316- remove duplicate letters - stack - greedy - string