当前位置:网站首页>[wechat applet] label (86/100)
[wechat applet] label (86/100)
2022-07-25 04:43:00 【lichong951】

Function description
To improve the usability of form components .
Use for Attribute found corresponding id, Or put the control under the label , When clicked , Will trigger the corresponding control . for Priority over internal controls , Trigger the first control by default when there are multiple controls inside . At present, there are :button, checkbox, radio, switch, input.
UI Layout :
<!--pages/label/label.wxml-->
<view class="page-section-title"> The form component is in label Inside </view>
<checkbox-group class="group" bindchange="checkboxChange">
<view class="label-1" wx:for="{
{checkboxItems}}">
<label>
<checkbox value="{
{item.name}}" checked="{
{item.checked}}"></checkbox>
<text class="label-1-text">{
{
item.value}}</text>
</label>
</view>
</checkbox-group>
<view class="page-section-title">label use for Identify form components </view>
<radio-group class="group" bindchange="radioChange">
<view class="label-2" wx:for="{
{radioItems}}">
<radio id="{
{item.name}}" value="{
{item.name}}" checked="{
{item.checked}}"></radio>
<label class="label-2-text" for="{
{item.name}}"><text>{
{
item.name}}</text></label>
</view>
</radio-group>
<view class="page-section-title">label Select the first one when there are multiple </view>
<label class="label-3">
<checkbox class="checkbox-3"> Option one </checkbox>
<checkbox class="checkbox-3"> Option 2 </checkbox>
<view class="label-3-text"> Click this label The first one is selected by default for the text under checkbox</view>
</label>
style :
/* pages/label/label.wxss */
.label-1, .label-2{
margin: 30rpx 0;
}
.label-3-text{
color: #576B95;
font-size: 28rpx;
}
.checkbox-3{
display: block;
margin: 30rpx 0;
}
Data model & control
// pages/label/label.js
Page({
/** * Initial data of the page */
data: {
checkboxItems: [
{
name: 'USA', value: ' The United States '},
{
name: 'CHN', value: ' China ', checked: 'true'}
],
radioItems: [
{
name: 'USA', value: ' The United States '},
{
name: 'CHN', value: ' China ', checked: 'true'}
],
hidden: false
},
checkboxChange(e) {
const checked = e.detail.value
const changed = {
}
for (let i = 0; i < this.data.checkboxItems.length; i++) {
if (checked.indexOf(this.data.checkboxItems[i].name) !== -1) {
changed['checkboxItems[' + i + '].checked'] = true
} else {
changed['checkboxItems[' + i + '].checked'] = false
}
}
this.setData(changed)
},
radioChange(e) {
const checked = e.detail.value
const changed = {
}
for (let i = 0; i < this.data.radioItems.length; i++) {
if (checked.indexOf(this.data.radioItems[i].name) !== -1) {
changed['radioItems[' + i + '].checked'] = true
} else {
changed['radioItems[' + i + '].checked'] = false
}
}
this.setData(changed)
},
tapEvent() {
console.log(' Button clicked ')
},
/** * Life cycle function -- Monitor page loading */
onLoad(options) {
},
Attribute specification
attribute type The default value is Required explain Minimum version
for string no Bound to control id 1.0.0
边栏推荐
- Grafana visual configuration diagram histogram
- In depth understanding of service
- Definition and basic terms of tree
- PHP Baidu qianqianhua installment API
- What is behind the development of science and technology now is the advent of the era of the meta universe
- 2019 telecast retest test questions
- Perspective
- How to use ide tool hhdbcs to create a data table containing 1000 simulated data in Oracle database, and
- LVGL 8.2 Textarea
- Paper:《Peeking Inside the Black Box: Visualizing Statistical Learning with Plots of Individual Condi
猜你喜欢

Huawei cloud from entry to actual combat | cloud rapid site establishment service and enterprise host security service
![[sht30 temperature and humidity display based on STM32F103]](/img/43/bbc66ab2d56cfa9dc05d795e8fe456.jpg)
[sht30 temperature and humidity display based on STM32F103]

开源之夏专访|“00 后” PMC member 白泽平

IT自媒体高调炫富,被黑客组织盯上,铁定要吃牢饭了…

Unity3d learning note 9 - loading textures

Token value replacement of burpsuite blasting

ESWC 2018 | r-gcn: relational data modeling based on graph convolution network

运筹学基础【一】 之 导论

Ffmpeg download and installation

Swagger simple quick start tutorial
随机推荐
What causes the wait event of TCP socket (kgas) in oracle?
读书的思考
Database design process
When the development of the meta universe begins to show more and more the style of the Internet, we need to be vigilant
Cannot make qopenglcontext current in a different thread: the solution to pyqt multithread crash
I didn't expect Mysql to ask these questions
LVGL 8.2 Tabview
[cloud picture theory] 247 first introduction to Huawei cloud analysis service
C# 之 FileStream类介绍
Anaconda installs jupyter
1. If function of Excel
# 1. Excel的IF函数
Salt and ice particles cannot be distinguished
Dark king | analysis of zego low illumination image enhancement technology
数据链路层协议 ——— 以太网协议
@ResponseBody注解的总结
Huawei cloud from entry to actual combat | cloud rapid site establishment service and enterprise host security service
数据湖(十六):Structured Streaming实时写入Iceberg
Tiny-emitter.js: a small event subscription and Publishing Library
It we media shows off its wealth in a high profile, and is targeted by hacker organizations. It is bound to be imprisoned