success (res) {
for (let i = 0; i < res.data.uesrs.length; i++) {
let obj_json = res.data.uesrs[i].hashtag;
let obj_jsons = JSON.parse(obj_json).imageList;
that.setData({
obj_json: obj_jsons
})
}
that.setData({
dataList: res.data.uesrs
})
}
<view class="card" wx:for="{{dataList}}" wx:key="id">
<view class="title">{{item.content}}</view>
<view class="title" id="{{item.id}}" bindtap="dailyDetail">{{common.getGap(item.last)}}</view>
<view wx:for="{{obj_json}}" wx:for-item="obj" wx:key="key">
<view>{{obj.fileUrl}}</view>
</view>
</view>
只循环了最后一条,而不是对应显示,麻烦大家帮忙看看,谢谢了。
obj_json只有一个,你wxml里不管循环多少次,那值可不就是一个么?
success (res) {
for (let i = 0; i < res.data.uesrs.length; i++) {
let obj_json = res.data.uesrs[i].hashtag;
let obj_jsons = JSON.parse(obj_json).imageList;
res.data.uesrs[i].obj_jsons = obj_jsons
}
that.setData({
dataList: res.data.uesrs
})
}
<view class="card" wx:for="{{dataList}}" wx:key="id">
<view class="title">{{item.content}}</view>
<view class="title" id="{{item.id}}" bindtap="dailyDetail">{{common.getGap(item.last)}}</view>
<view wx:for="{{item.obj_json}}" wx:for-item="obj" wx:key="key">
<view>{{obj.fileUrl}}</view>
</view>
</view>