当前位置:网站首页>小程序常用组件小结
小程序常用组件小结
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>
边栏推荐
- Use and principle of wait notify
- LRU cache for leveldb source code analysis
- 使用 Nocalhost 开发 Rainbond 上的微服务应用
- Pico neo3 handle grabs objects
- Use and principle of reentrantlock
- Programmers dig "holes" to get rich: if they find a loophole, they will be rewarded 12.72 million yuan
- Rainbond结合NeuVector实践容器安全管理
- Manually implement a simple stack
- 3D建模與處理軟件簡介 劉利剛 中國科技大學
- Unity drags and modifies scene camera parameters under the editor
猜你喜欢
智慧运维:基于 BIM 技术的可视化管理系统
One click deployment of highly available emqx clusters in rainbow
STM32 expansion board digital tube display
Distributed transactions - Solutions
Detailed explanation of set
CockroachDB 分布式事务源码分析之 TxnCoordSender
数字金额加逗号;js给数字加三位一逗号间隔的两种方法;js数据格式化
使用 Nocalhost 开发 Rainbond 上的微服务应用
How to traverse massive data in redis
Summary of spanner's paper
随机推荐
Global and Chinese market of mainboard 2022-2028: Research Report on technology, participants, trends, market size and share
FileOutPutStream
如何开始学剪辑?零基础详细解析
Design and application of immutable classes
One click deployment of highly available emqx clusters in rainbow
Intelligent operation and maintenance: visual management system based on BIM Technology
[RootersCTF2019]babyWeb
Set集合详细讲解
Software intelligence: the "world" and "boundary" of AI sentient beings in AAAs system
Actual combat: gateway api-2022.2.13
Flutter can refresh data every time the interface comes in
Flutter 实现每次进来界面都刷新数据
Summary of spanner's paper
STM32 expansion board digital tube display
Leetcode522- longest special sequence ii- hash table - String - double pointer
What can the points mall Games bring to businesses? How to build a points mall?
[daily question in summer] function of rogu p3742 UMI
Worried about infringement? Must share copyrightless materials on the website. Don't worry about the lack of materials for video clips
Explanation of characteristics of hydraulic slip ring
How to select conductive slip ring material