后台返回的数组里面有两个对象 每个对象都有图片路径字段 但是显示都是在同一个组件中 src只能显示一张图片路径如果是https://fms.yinxinht.com/UploadFile/2021-03-31/nPd…042f2e6b0989352f31f8720fc6f402971617190887459.jpg", "https://fms.yinxinht.com/UploadFile/2021-03-31/xja…dbfe3be38456428ab4d79c85a9eeb5201617190849879.jpg"多张图片该怎么做呢
wx:for循环渲染image组件不行吗
//page.wxml
<view wx:for="{{list}}" wx:for-iterm="item" wx:key="item">
<image wx:for="{{item.imgUrl}}" wx:for-iterm="idx" wx:key="idx" src="{{idx}}" />
</view>
//page.js
Page({
data: {
list: [{
id: 0,
imgUrl: ["https://qq.com/1.png", "https://qq.com/2.png"]
}, {
id: 1,
imgUrl: ["https://qq.com/3.png", "https://qq.com/4.png"]
}, {
id: 2,
imgUrl: ["https://qq.com/5.png", "https://qq.com/6.png"]
}]
}
})
console.log(wxMsgT);
//把数组里每个图片路径字段取出来放到一个空数组里
var dataArray = [];
for (var i = 0; i < wxMsgT.length; i++) {
dataArray[i] = wxMsgT[i].ImageUrls.split(",")
}
console.log(dataArray);
that.setData({
wxMsgs: wxMsgT,
imgss: dataArray
// imgss: ps.length == 1 ? ["http://iph.href.lu/60x60?text=default"] : ps
})
}
})
<view class="weui-uploader">
<view class="img-v weui-uploader__bd">
<view class='pic'>
<image wx:for="{{ imgss }}" wx:for-item="xy" wx:key="xy" class='weui-uploader__img '
style=" width:200rpx;height:200rpx" src="{{ xy }}" data-index="{{index}}" mode="aspectFill"
bindtap="previewImgs" data-list="{{ dayItem.ImageUrls }}" data-src="{{ dayItem.ImageUrls }}">
<!-- <icon type='cancel' class="delete-btn" data-index="{{index}}" catchtap="deleteImg" data-val="{{item}}"></icon> -->
</image>
</view>
</view>
</view>