使用chooseMedia,选择一张图片之后,展示了无数张图片,并且没有显示出图片,如图:
报错如图:
代码:
<view wx:for="{{tempImages}}" wx:key="item" class="image-group" style="width:{{imageSize}}px;height:{{imageSize}}px;">
<image src="{{item}}"></image> 注:如果把item改成tempImages就可以展示出图片,但是不能解决重复问题,除非取消wx:for循环
<view class="close-btn" bind:tap="onRmoveBtnTap" data-index="{{index}}"></view>
</view>
js代码:
onAddImageTap(){
const that = this;
wx.chooseMedia({
count:9,
mediaType:['image'],
sourceTypr:['album','camera'],
success(res){
const tempImages = res.tempFiles[0].tempFilePath;
// const oldImages = that.data.tempImages;
// const newImages = oldImages.concat(tempImages);
that.setData({
// tempImages:newImages
注:如写了注销的这段代码就能够正常展示,但是一次只能够选择一张图片,
哪怕选择了3张图片,展示的还是一张图片
tempImages:tempImages
})
}
})
},
