解决wx.previewImage不能对应显示(总显示第一张)
发布于 4 年前 作者 bhu 4516 次浏览 来自 分享

wxml页面代码:

<view class="bg-img" wx:for="{{goodsDetail.goodsImgFileIDList}}" wx:key="index"  >

          <image mode='aspectFill' src="{{item}}" data-index="{{index}}" bindtap="ViewImage" />

</view>

js页面代码:

//展示图片

  ViewImage(e) {

    let index = e.currentTarget.dataset.index

    let imgAry = this.data.goodsDetail.goodsImgFileIDList //自己要显示图片的数组

    wx.previewImage({

      urls: imgAry,

      current: imgAry[index]

    })

  },

回到顶部