当前位置:网站首页>Common components of wechat applet
Common components of wechat applet
2022-07-19 05:37:00 【One finger quicksand Q】
Catalog
One 、 Common view container class components
Two 、 Common basic content components
3、 ... and 、 Other common components
One 、 Common view container class components
① view
- Normal view area
- Be similar to HTML Medium div, Is a block level element
- Commonly used to achieve the layout effect of the page
attribute | explain | |
text-align | Used to set the text alignment in the element . Valid only for text , Invalid for element , Cannot set the alignment of elements ; | |
line-height | Row height , When line-height=height, Writing in the middle | |
display:flex | Elastic box : It determines the distribution of one box in other boxes , And how to deal with the available space . Use the model , You can easily create " The adaptive " Flow layout of browser window . | |
justify-content | attribute | explain |
flex-start | Arranged on the leftmost side of the current row | |
flex-end | Arranged on the far right of the current row | |
center | Arrange in the middle of the current row | |
space-between | Equally spaced , Leave no space on either side | |
space-around | Equally spaced , The space left on both sides is equal to half of the space |
first.wxml
<view class="container1">
<view>A</view>
<view>B</view>
<view>C</view>
</view>
first.wxss
.container1 view {
width: 100px;
height: 100px;
text-align: center;
line-height: 100px;
}
.container1 view:nth-child(1) {
background-color: lightgreen;
}
.container1 view:nth-child(2) {
background-color: lightskyblue;
}
.container1 view:nth-child(3) {
background-color: lightcoral;
}
.container1 {
display: flex;
justify-content: space-around;
}
② scroll-view
- Scrollable view area
- It is often used to achieve the effect of scrolling lists
second.wxml
<scroll-view class="container1" scroll-y>
<view>A</view>
<view>B</view>
<view>C</view>
</scroll-view>
second.wxss
.container1 view {
width: 100px;
height: 100px;
text-align: center;
line-height: 100px;
}
.container1 view:nth-child(1) {
background-color: lightgreen;
}
.container1 view:nth-child(2) {
background-color: lightskyblue;
}
.container1 view:nth-child(3) {
background-color: lightcoral;
}
.container1 {
border: 1px solid red;
height: 120px;
width: 100px;
}
③ swiper and swiper-item
- Carousel map container assembly and Shuffling figure item Components
attribute | type | The default value is | explain |
indicator-dots | boolean | false | Display panel indicator |
indicator-color | color | rgba(0, 0, 0, .3) | Indicate the color |
indicator-active-color | color | #000000 | The currently selected indicator color |
autoplay | boolean | false | Auto switch or not |
interval | number | 5000 | Auto switch interval |
circular | boolean | false | Whether to adopt the joint sliding |
third.wxml
<swiper class="swiper-container" indicator-dots>
<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>
third.wxss
.swiper-container {
height: 150px;
}
.item {
height: 100%;
line-height: 150px;
text-align: center;
}
swiper-item:nth-child(1) .item {
background-color: lightgreen;
}
swiper-item:nth-child(2) .item {
background-color: lightblue;
}
swiper-item:nth-child(3) .item {
background-color: lightpink;
}
Two 、 Common basic content components
① text
- Text component
- Be similar to HTML Medium span label , It's an in-line element
adopt text Component's selectable attribute , Long press the selected text content :
fouth.wxml
<view>
The mobile phone supports the long press selection effect
<text selectable>13800005006</text>
</view>
② rich-text
- Rich text component
- Support HTML The string is rendered as WXML structure
adopt rich-text Component's nodes Attribute node , hold HTML The string is rendered as the corresponding UI structure :
fifth.wxml
<rich-text nodes="<h1 style='color: red;'> title </h1>"></rich-text>
3、 ... and 、 Other common components
① button
- Button components
- Functional ratio HTML Medium button Rich buttons
- adopt open-type Attribute can call various functions provided by wechat ( Customer service 、 forward 、 Get user authorization 、 Access to user information, etc )
sixth.wxml
<button> Default button </button>
<button type="primary"> Main tone button </button>
<button type="warn"> Warning button </button>
<button size="mini"> Default button </button>
<button type="primary" size="mini"> Main tone button </button>
<button type="warn" size="mini"> Warning button </button>
<button size="mini" plain> Default button </button>
<button type="primary" size="mini" plain> Main tone button </button>
<button type="warn" size="mini" plain> Warning button </button>
② image
- Picture components image
- The default width of the component is about 300px、 The height is about 240px
image Component's mode Property is used to specify the cropping and scaling mode of the picture , frequently-used mode The property values are as follows :
mode value | explain |
scaleToFill | ( The default value is ) Zoom mode , Do not keep aspect ratio zooming picture , Stretch the width and height of the picture completely to fill image Elements |
aspectFit | Zoom mode , Keep the aspect ratio scaled , Make the long edges of the picture fully visible . in other words , The picture can be displayed completely . |
aspectFill | Zoom mode , Keep the aspect ratio scaled , Only make sure that the short side of the picture is fully displayed . in other words , Pictures are usually complete only horizontally or vertically , Intercept will occur in the other direction . |
widthFix | Zoom mode , The width does not change , Automatic height change , Keep the aspect ratio of the original image unchanged |
heightFix | Zoom mode , The height remains the same , The width changes automatically , Keep the aspect ratio of the original image unchanged |
seventh.wxml
<image></image>
<image src="/images/1.jpg"></image>
seventh.wxss
image {
border: 1px solid red;
}
③ navigator
- Page navigation component
- Be similar to HTML Medium a link
Property name | type | The default value is | explain |
navigationBarTitleText | String | character string | Navigation bar title text content |
navigationBarBackgroundColor | HexColor | #000000 | Navigation bar background color , Such as #000000 |
navigationBarTextStyle | String | white | Navigation bar Title Color , Support only black / white |
1. Set the title of the navigation bar
Setup steps :app.json -> window -> navigationBarTitleText demand : Put the title on the navigation bar , From the default “WeChat” It is amended as follows “ Black horse programmer ”, The effect is shown in the figure :
2. Set the background color of the navigation bar
Setup steps :app.json -> window -> navigationBarBackgroundColor demand : Change the background color of the navigation bar title , From the default #fff It is amended as follows #2b4b6b , The effect is shown in the figure :
3. Set the title color of the navigation bar
Setup steps :app.json -> window -> navigationBarTextStyle demand : Color the title on the navigation bar , From the default black It is amended as follows white , The effect is shown in the figure :
Be careful : navigationBarTextStyle The optional values for are black and white
Wechat applet development document :view | Wechat open documents (qq.com)
Share the learning notes website I created :George's Notes (gitee.io)
边栏推荐
- Spark核心编程(4)--Spark运行架构
- Advanced operation of C language
- MySQL学习笔记(4)——(基本CRUD)操作数据库中的表的数据
- Data Lakehouse的未来-开放
- Is the cookie valid for a limited time? How to set cookies? Teach you to set by hand
- 4.东软跨境电商数仓项目--数据采集通道搭建之用户行为数据采集通道搭建(2022.6.1-2022.6.4)
- C language dynamic memory management
- Application of recursion
- 软件过程与管理复习(十)
- C语言的高级操作
猜你喜欢
1. Dongsoft Cross - Border E - commerce Data Warehouse Requirement specification document
gradle自定义插件
5.1 business data acquisition channel construction of data acquisition channel construction
10.数据仓库搭建之DWD层搭建
Scala primary practice - statistics of mobile phone traffic consumption (1)
Is the software testing training of lemon class reliable? This successful case of counter attack from the training class tells you
【全网首发】主线程异常会导致 JVM 退出?
Pointer array & array pointer
10. DWD layer construction of data warehouse construction
微信小程序之计算器
随机推荐
图片的大小限制显示
7.数据仓库搭建之数据仓库环境准备
关于Kotlin泛型遇到的问题
Use iceberg in CDP to pressurize the data Lake warehouse
Idea import local package
11. DWS layer construction of data warehouse construction
jvm学习
1. Neusoft cross border e-commerce warehouse demand specification document
MySQL installation and configuration tutorial (super detailed)
Common methods of goframe error handling & use of error codes
MySQL queries the data of the current day, this week, this month and last month
Syntax differences between PgSQL and Oracle (SQL migration records)
C语言&位域
Solve idea new module prompt module XXXX does exits
Advanced operation of C language
编程风格
Some applications of special pointers
Data Lakehouse的未来-开放
Rxjs source code analysis (I) observable
Spark core programming (4) -- spark operation architecture