<view wx:for="{{imgalist}}"wx:for-item="image"class="previewimg">
<image src="{{image}}" data-src="{{image}}" data-index="{{index}}" bindtap="previewImage" class='img'></image>
</view>
data: {
imgalist: ['https://www.cslpyx.com/weiH5/jrx.jpg', 'https://www.cslpyx.com/weiH5/mmd.jpg'],
},
previewImage: function (e) {
let that=this;
let index = e.currentTarget.dataset.index;
wx.previewImage({
current: this.data.imgalist[index], // 当前显示图片的http链接
urls: this.data.imgalist // 需要预览的图片http链接列表
})
wx.getImageInfo({// 获取图片信息(此处可不要)
src: 'https://www.cslpyx.com/weiH5/jrkj.jpg',
success: function (res) {
console.log(res.width)
console.log(res.height)
}
})
}
小程序文档:https://developers.weixin.qq.com/miniprogram/dev/api/media/image/wx.previewImage.html
转载地址:https://blog.csdn.net/csl125/article/details/79085597/
如果有帮到你的话,欢迎激励一下作者。