官方文档没有bug,事件绑定要绑定在image组件上,而不是绑定在view组件上
wx.previewImage参数current的BUG?问题描述 : [图片] previewImage current (当前显示图片的链接,不填则默认为 urls 的第一张) 默认了current 后还是显示的 urls 列表中的第一张图片 反馈图如下: [图片] [图片] [图片] 代码如下 wxml文件[代码]<[代码][代码]view[代码] [代码]class[代码][代码]=[代码][代码]"img_item"[代码] [代码]wx:for[代码][代码]=[代码][代码]"{{picList}}"[代码] [代码]wx:for-item[代码][代码]=[代码][代码]"item"[代码][代码]>[代码][代码] [代码][代码]<[代码][代码]image[代码] [代码]src[代码][代码]=[代码][代码]"{{item.url}}"[代码] [代码]bindtap[代码][代码]=[代码][代码]"viewPic"[代码] [代码]data-url[代码][代码]=[代码][代码]"{{item.url}}"[代码][代码]></[代码][代码]image[代码][代码]>[代码][代码]</[代码][代码]view[代码][代码]>[代码] js文件 [代码]viewPic:[代码][代码]function[代码][代码](e)[代码][代码] [代码][代码]{[代码][代码] [代码][代码]var[代码] [代码]_this = [代码][代码]this[代码][代码];[代码][代码] [代码][代码]var[代码] [代码]nowpic = e.target.dataset.url;[代码][代码] [代码] [代码] [代码][代码]var[代码] [代码]picList = _this.data.picList;[代码][代码] [代码][代码]var[代码] [代码]urls = [];[代码][代码] [代码][代码]for[代码] [代码]([代码][代码]var[代码] [代码]i = 0; i < picList.length; i++)[代码][代码] [代码][代码]{[代码][代码] [代码][代码]//console.log(picList[i].url);[代码][代码] [代码][代码]urls.push([代码][代码]picList[i].url);[代码][代码] [代码][代码]} [代码][代码] [代码][代码]console.log(nowpic);[代码][代码] [代码][代码]wx.previewImage({[代码][代码] [代码][代码]current: nowpic, [代码][代码]// 当前显示图片的http链接[代码][代码] [代码][代码]urls: urls, [代码][代码]// 需要预览的图片http链接列表[代码][代码] [代码][代码]})[代码][代码] [代码] [代码] [代码][代码]},[代码]
2022-04-17