因为样式的原因我把请求回来的数据放在数组对应的数组下面了 但是页面渲染的时候发现出不来 找不到什么原因
我创建的数组
newlist:[[],[],[],[],[],[],[],[],[],[],[],[],[],[],[],[]],
请求之后添加数据
that.data.newlist[cur].push(e)
渲染页面的时候没出来
<swiper-item wx:for="{{newlist}}" wx:key="*this" wx:for-index="index">
{{index}}
<view class="group-cell" wx:for="{{newlist[index]}}" wx:for-item="cell" wx:for-index="cellindex">
{{cell.news_id}}
{{cell.category_id}}
</view>
</swiper-item>
我测试的数组
newlists:[[], [{ news_id: 694361, category_id: 90, user_id: 3565692, promulgator_id: 5180890, news_type: 1 }, { news_id: 694363, category_id: 90, user_id: 1, promulgator_id: 5181278, news_type: 1 }, { news_id: 694348, category_id: 90, user_id: 1, promulgator_id: 5180889, news_type: 1 }]
, [{ news_id: 694337, category_id: 90, user_id: 1, promulgator_id: 5181278, news_type: 1 }, { news_id: 694325, category_id: 90, user_id: 1, promulgator_id: 5180888, news_type: 2 }, { news_id: 694328, category_id: 90, user_id: 1, promulgator_id: 3607, news_type: 1,}],[],[]],
是可以渲染的
上面是我创建的数组并添加的数据 下面是我测试的数据 格式都是一样的 上面的出不来 下面的能出来 找了很久都没找到原因在哪
小程序给数组push数据是不会触发视图更新的,你需要push数据后再set一下数据,才能触发视图更新: