在微信小程序中使用 previewImage() 预览图片时,如果 e.currentTarget.id 为空,可能是因为当前事件的触发对象没有设置 id 属性,或者 id 属性值为空。

请检查代码和触发事件的元素,确保 id 属性已正确设置。

例如,如果你的代码如下:

predivImage(e) {
  console.log(e);
  wx.previewImage({
    current: e.currentTarget.id, // 当前显示图片的http链接
    urls: this.pictureList // 需要预览的图片http链接列表
  });
},

请检查 e.currentTarget 对象是否包含 id 属性,以及该属性的值是否为空。如果为空,则需要在触发事件的元素上添加 id 属性,并设置一个非空的值。

微信小程序 previewImage() 中 e.currentTarget.id 为空的原因及解决方法

原文地址: http://www.cveoy.top/t/topic/nyN6 著作权归作者所有。请勿转载和采集!

免费AI点我,无需注册和登录