当前位置:网站首页>[wechat applet] checkbox (89/100)
[wechat applet] checkbox (89/100)
2022-07-20 12:10:00 【lichong951】
UI Layout :
<!--pages/CheckBox/CheckBox.wxml-->
<view class="page-section-title"> Default style </view>
<checkbox value="cb" checked="true" /> Choose
<checkbox value="cb" /> Not selected
<view> Recommended display style </view>
<checkbox-group bindchange="checkboxChange">
<label wx:for="{
{items}}" wx:key="{
{item.value}}">
<view >
<checkbox value="{
{item.value}}" checked="{
{item.checked}}" />
</view>
<view >{
{
item.name}}</view>
</label>
</checkbox-group>
Data model & The controller is as follows :
// pages/CheckBox/CheckBox.js
Page({
/** * Initial data of the page */
data: {
items: [
{
value: 'BJ', name: ' Beijing '},
{
value: 'HeB', name: ' hebei ', checked: 'true'},
{
value: 'HeNan', name: ' Henan '},
{
value: 'HuB', name: ' hubei '},
{
value: 'HuNan', name: ' hunan '},
{
value: 'ANH', name: ' anhui '}
]
},
checkboxChange(e) {
console.log('checkbox happen change event , carry value The value is :', e.detail.value)
const items = this.data.items
const values = e.detail.value
for (let i = 0, lenI = items.length; i < lenI; ++i) {
items[i].checked = false
for (let j = 0, lenJ = values.length; j < lenJ; ++j) {
if (items[i].value === values[j]) {
items[i].checked = true
break
}
}
}
this.setData({
items
})
},
/** * Life cycle function -- Monitor page loading */
onLoad(options) {
},
Function description
Multiple choice items .
Attribute specification
attribute type The default value is Required explain Minimum version
value string no checkbox identification , Trigger when selected checkbox-group Of change event , And carry checkbox Of value 1.0.0
disabled boolean false no Whether to disable 1.0.0
checked boolean false no Currently selected , Can be used to set the default selection 1.0.0
color string #09BB07 no checkbox The color of the , Same as css Of color 1.0.0
边栏推荐
猜你喜欢
DOM events of DOM series
VS2017 OpenCV3.4.2 通过Release的版本 源码编译成 x86
Okaleido or get out of the NFT siege, are you optimistic about it?
什么是反向代理?
Resolved (selenium reports an error) attributeerror: 'webdriver' object has no attribute 'execute_ cdp_ cmd‘
SPEC2006详细参数和测试过程常见问题处理总结(附实例操作)
ERP capability planning and scheduling
DeFi 2.0的LaaS协议Elephant,重振DeFi赛道发展的关键
产品经理必不可少的证书!
【小程序】小游戏到底是个啥?
随机推荐
Yunna - dynamic environment monitoring inspection table, information machine room inspection table
Okaleido or get out of the NFT siege, are you optimistic about it?
File, exception, module
Flask请求数据和获取响应
查询oracle11g日志的办法,数据库审计,记录排查
Cylindricity error evaluation method based on MATLAB
Design and Simulation of infinite impulse response digital filter based on MATLAB
What is reverse proxy?
HCIA-R&S自用笔记(12)路由基础、直连路由与静态路由
云呐-fsu动环监控单元,fsu动环监控单元是什么
什么是反向代理?
Matlab finite element calculation
Attribute operation of DOM series elements
Fractional PID control and vector control permanent magnet motor
小白学习MySQL - Generated Columns功能
transformers中BertPreTrainedModel使用说明
【微信小程序】input输入框(87/100)
美女直播首用LDR6028无线麦克风音质传输OTG充电持续输出
【异常】异常解决文章格式
【微信小程序】From表单(88/100)