-
Notifications
You must be signed in to change notification settings - Fork 323
Description
tdesign-miniprogram 版本
1.7.1
重现链接
No response
重现步骤
JS
const groupData = new Map() newVal.options.forEach(item => { const key = item.group_name if (!groupData.has(key)) { groupData.set(key, []) } groupData.get(key).push(item) }); if (groupData.size > 0) { groupData.forEach((value, key) => { const myArr = Array.from(value) myArr.sort(() => Math.random() - 0.5) groupData.set(key, myArr) }) const arr = [...groupData] this.setData({ group_options: arr }) } else { this.setData({ group_options: [{ key: '', value: newVal.options }] }) }
view
<t-checkbox-group value="{{checkboxValue}}" bind:change="handleGroupChange"> <block wx:for="{{group_options}}" wx:for-item="group" wx:for-index="g_index" wx:key="g_index"> <view class="group_title" wx:if="{{group[0] != ''}}">{{group[0]}}</view> <block wx:for="{{group[1]}}" wx:for-item="option" wx:for-index="o_key" wx:key="option.id"> <t-checkbox value="{{option.id}}"> </t-checkbox> </block> </block> </t-checkbox-group>
期望结果
checkbox的选中状态与checkboxValue一致。
实际结果
紧凑型
基础库版本
3.5.7
补充说明
多次重新渲染之后,由于myArr.sort(() => Math.random() - 0.5)这个进行乱序排序,导致checkbox的选中状态与checkboxValue不一样。
已经多次确定checkbox正确。
如果删除block直接在checkbox-group里面直接循环这个checkbox进行随机排序,也不会出现问题。