错误代码 , 条件筛选后,数据变少 只会更新数量条数,新数据不会重新渲染 ,因为key未更新 就不会重新渲染
<view
v-for="(good, goodIndex) in list"
:key="goodIndex"
>
<u-cell-group :border="false">
<ListingGoodCell
:ref="'goodCell'+ good.id"
:good="good"
/>
</u-cell-group>
</view>
正确写法:
<view
v-for="(good, goodIndex) in list"
:key="good.id + goodIndex"
>
<u-cell-group :border="false">
<ListingGoodCell
:ref="'goodCell'+ good.id"
:good="good"
/>
</u-cell-group>
</view>
数据更新id发生改变,则会更新,但id未number的话可能存在重复的情况,与更新前一致不会更新,再相加前转为string类型就好了
<view
v-for="(good, goodIndex) in list"
:key="good.id +''+ goodIndex"
>
<u-cell-group :border="false">
<ListingGoodCell
:ref="'goodCell'+ good.id"
:good="good"
/>
</u-cell-group>
</view>