升级到152900后,image组件的bindtap事件,取不到图片地址啦,

发布于 7 年前作者 tao2510914 次浏览最后编辑 7 年前来自 ask

<image src=“{{item.img}}” id=“{{index}}” bindtap=“previewImage” class=“photo” mode=“aspectFill” />

 //大图预览

  previewImage: function (e) {

    console.log(e);

    var current = e.target.dataset.src;

    wx.previewImage({

      current: current,

      urls: [current]

    })

  },

current是undefined!!

4 回复
xgu
xgu1 楼6 年前

我也有类似问题,不知道你解决了没有。

yan94
yan942 楼6 年前

<image data-src=“{{item.img}}” src=“{{item.img}}” id=“{{index}}” bindtap=“previewImage” class=“photo” mode=“aspectFill” />

data-src 这样

fang54
fang543 楼6 年前

加data-src获取src,如果想点击之后改变该图片呢,怎么替换当前元素的src,而不影响其他元素。因为我是遍历数组生成的列表,每一项都有一个image,每个image 点击之后要换src,不能影响到其他的image

xlei
xlei4 楼5 年前

看来只能加data-src了。之前是默认能取到的。