升级到152900后,image组件的bindtap事件,取不到图片地址啦,
发布于 6 年前 作者 tao25 10774 次浏览 来自 问答

<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 回复

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

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

data-src 这样

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

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

回到顶部