在页面onload的时候去request数据,成功后对数据进行处理,一个简单的for循环过滤数据,然后再push到页面需要的数组里,最后在页面wx:for这个数组拿到需要的数据,因为页面使用的是模板,调用的时候都需要传入数据格式一样的数据,所以想这么做,但是用for循环处理数据后,页面总是拿不到处理后的数据,上截图代码:
onload的时候取到数据后用for进行过滤:
页面上用wx:for引用数据
<import src='../template/template.wxml'/>
<scroll-view scroll-y class='myPic-wrapper'>
<block wx:for='{{myPic}}' wx:key='{{index}}' data-index='{{index}}' bindtap='myPicContent' class='myPic'>
<template is='collectList' data='{{...item}}'></template>
<view ></view>
</block>
</scroll-view>
data里的数据:
data:{
photoList:null,
myPic:[],
length:2
}
还请各位路过的大神帮忙看看这是什么问题,谢谢