收藏
回答

使用chooseMedia,选择图片后就重复,也不展示图片内容,这是什么问题?

在使用chooseMedia时,选择图片后,模拟器出现了N张图片,并且图片内容也没有展示出来,如图:

代码:

<view wx:for="{{tempImages}}" wx:key="item"  class="image-group" style="width:{{imageSize}}px;height:{{imageSize}}px;">
  <image src="{{item}}"></image> 
  <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){
    // console.log(res);
    const tempImages = res.tempFiles[0].tempFilePath;
    // const oldImages = that.data.tempImages;
    // const newImages = oldImages.concat(tempImages);    
          that.setData({
       //  tempImages:newImages 
             注:如果使用注销的这段代码,在模拟器中可以正常展示,但是哪怕选择了4张图片,
                只展示一张图片,需要一张一张的添加才能够正常展示
       tempImages:tempImages
     })
    }
  })
},
回答关注问题邀请回答
收藏

1 个回答

  • 社区技术运营专员-Jahozheng
    社区技术运营专员-Jahozheng
    2024-05-15

    请具体描述问题出现的流程,并提供能复现问题的简单代码片段(https://developers.weixin.qq.com/miniprogram/dev/devtools/minicode.html)。

    2024-05-15
    有用
    回复
登录 后发表内容