知识学堂 > 课程 > 小程序多选按钮

小程序多选按钮

发布日期:2020/11/24 来源:聚恒【返回】

一般不需要用到子元素,父元素数组取值就好



 <view wx:for="{{list}}" wx:key="id"> <checkbox value="{{item.id}}" data-id="{{item.id}}" bindtap="check"></checkbox> </view> 
choose(e) { this.data.newList = e.detail.value; console.log("group事件:",this.data.newList);
},
check(e) { let id = e.currentTarget.dataset.id; console.log("当前checkBox事件:",id); if(this.data.newList.contains(""+id)){ console.log("选中:"+id);
    } else { console.log("取消选中:"+id);
    }
},