不得不吐糟下checkbox默認(rèn)樣式真是有點(diǎn)略丑?。?!checkbox組件為一個多選框被放到checkbox-group組中,并在checkbox-group(只能包含checkbox)中設(shè)置監(jiān)聽事件。
checkbox-group監(jiān)聽方法:
checkbox多選屬性:
wxml
<!--checkbox-group就是一個checkbox組 有個監(jiān)聽事件bindchange,監(jiān)聽數(shù)據(jù)選中和取消-->
<checkbox-group bindchange="listenCheckboxChange">
<!--這里用label顯示內(nèi)容,for循環(huán)寫法 wx:for-items 默認(rèn)item為每一項(xiàng)-->
<label style="display: flex;" wx:for-items="{{items}}">
<!--value值和默認(rèn)選中狀態(tài)都是通過數(shù)據(jù)綁定在js中的-->
<checkbox value="{{item.name}}" checked="{{item.checked}}"/>{{item.value}}
</label>
</checkbox-group>
js