data?
riderCommentList: [{
value: '安全',
selected: false,
title: '安全',
field: 'topic6'
}, {
value: '颜值',
selected: false,
title: '颜值',
field: 'topic3'
}, {
value: '功能',
selected: false,
title: '功能',
field: 'topic7'
},{
value: '没有',
selected: false,
title: '没有',
field: 'topic5'
}],
wxml?
<block wx:for="{{riderCommentList}}" wx:key="key">
<view bindtap="checkboxChange" class="recent-button {{item.selected ? 'btn-selected' : ''}}" checked="{{item.selected}}" data-index="{{index}}" data-text="{{item.value}}">
{{item.value}}</view>
</block>
?js
checkboxChange: function (e) {
let string = "riderCommentList[" + e.target.dataset.index + "].selected"
this.setData({
[string]: !this.data.riderCommentList[e.target.dataset.index].selected
})
let detailValue = this.data.riderCommentList.filter(it => it.selected).map(it => it.value)
console.log(this.data.riderCommentList)
},
|