当前位置:网站首页>小程序常用组件小结
小程序常用组件小结
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>

边栏推荐
- Global and Chinese market for kitchen range hoods 2022-2028: Research Report on technology, participants, trends, market size and share
- Redis数据库的部署及常用命令
- Global and Chinese markets of superconductor 2022-2028: Research Report on technology, participants, trends, market size and share
- C WPF uses dockpanel to realize screenshot box
- 0xc000007b the application cannot start the solution normally (the pro test is valid)
- Global and Chinese markets of gps/gnss receiver modules 2022-2028: Research Report on technology, participants, trends, market size and share
- Causes of short circuit of conductive slip ring and Countermeasures
- How to start learning editing? Detailed analysis of zero basis
- Daily question -leetcode1175- permutation of prime numbers - Mathematics
- [NLP Li Hongyi] notes
猜你喜欢

Set集合详细讲解

el-form表单新增表单项动态校验;el-form校验动态表单v-if不生效;

复制宝贝提示材质不能为空,如何解决?

Distributed - summary list

LeetCode522-最长特殊序列II-哈希表-字符串-双指针

Go learning notes (5) basic types and declarations (4)

Unity drags and modifies scene camera parameters under the editor

Rainbond结合NeuVector实践容器安全管理

Distributed architecture system splitting principles, requirements and microservice splitting steps

Detailed explanation of distributed global unique ID solution
随机推荐
Use and principle of AQS related implementation classes
Explanation of characteristics of hydraulic slip ring
Use of STM32 expansion board temperature sensor and temperature humidity sensor
Introduction of 3D Modeling and Processing Software Liu Ligang, Chinese University of Science and Technology
Use and principle of wait notify
实战:redux的基本使用
AcWing 889. 01 sequence satisfying the condition (Cartland number)
Intelligent operation and maintenance: visual management system based on BIM Technology
[Yugong series] February 2022 Net architecture class 005 ABP vNext Net core web application getting started configuration
Variable binding and deconstruction for rudimentary rust
Leetcode522- longest special sequence ii- hash table - String - double pointer
Introduction to 3D modeling and processing software Liu Ligang University of science and technology of China
[daily question in summer] Luogu p7222 [rc-04] informatics competition
Detailed explanation of set
[RootersCTF2019]babyWeb
Dynamic verification of new form items in El form; El form verifies that the dynamic form V-IF does not take effect;
LeetCode1497-检查数组对是否可以被 k 整除-数组-哈希表-计数
Global and Chinese market for instant messaging security and compliance solutions 2022-2028: Research Report on technology, participants, trends, market size and share
Solution: thread 1:[< *> setvalue:forundefined key]: this class is not key value coding compliant for the key*
Global and Chinese market of paper machine systems 2022-2028: Research Report on technology, participants, trends, market size and share