小程序修改checkbox的默认样式和图标多选

小程序修改checkbox的默认样式和图标多选
话不多说上代码
在这里插入图片描述

    <checkbox-group bindchange="checkboxChange" data-item="{{item.name}}" style=" display: flex;flex-wrap: wrap;flex-direction: row;height: 180rpx;margin-top:10px;width: 400px;">
  <label  
  style=" display: flex; position: relative;margin-right:30rpx;text-align:center;justify-content:center;margin-bottom:10px; line-height: 64rpx;" wx:for="{{items}}" wx:key="{{item.value}}">
            
    <view class="weui-cell__hd">
              <checkbox value="{{item.value}}" checked="{{item.checked}}"/>
            </view>
            <view  style="font-size: 20rpx; position: absolute; color: #06B8A5;">{{item.name}}</view>
          </label>
        </checkbox-group>
  checkbox .wx-checkbox-input {
      width: 128rpx; /* 背景的宽 */
      height: 64rpx; /* 背景的高 */
      /* width: 20%;
      height: 64rpx; */
      border-radius: 4px;
      border: 1px solid #F0FAF9;
      display: flex;
      align-items: center;
      justify-content: center;
      background: #FFFFFF;
      color: #06B8A5 !important; 
      color: red;
    }
    
   checkbox .wx-checkbox-input.wx-checkbox-input-checked {
      background: #F0FAF9; 
 color: #06B8A5 !important; 
      border: 1rpx solid #fff;
      /* background: red;
      text-color: red; */
    }
    
  
  checkbox .wx-checkbox-input.wx-checkbox-input-checked::before{
          width: 128rpx; /* 背景的宽 */
          height: 64rpx; /* 背景的高 */
          line-height: 40rpx;  
          text-align: center;
          font-size:30rpx; /* 对勾大小 30rpx */
          color:#fff; /* 对勾颜色 白色 */
          background: transparent;
          transform:translate(-50%, -50%) scale(1);
          -webkit-transform:translate(-50%, -50%) scale(1);
          /* color: red; */
          }

```javascript
在这里插入代码片

items: [
{value: ‘1’, name: ‘独立阳台’},
{value: ‘2’, name: ‘独立卫生间’ },
{value: ‘3’, name: ‘电视机’},
{value: ‘4’, name: ‘洗衣机’},
{value: ‘5’, name: ‘燃气灶’},
{value: ‘6’, name: ‘冰箱’},
{value: ‘7’, name: ‘wifi/宽带’, }
],
checkboxChange(e) {
// console.log(‘checkbox发生change事件,携带value值为:’, e.detail.value)
const items = this.data.items
const values = e.detail.value
// this.itemsarry = 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
}
}
}
// let form = this.data.form.radioarry
let form = this.data.form;
form.radioarry = e.detail.value
this.setData({
// items,
form:form
})
},


  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值