微信小程序放大预览

wxml代码:

< block wx:for= "{{listData.photo}}">
< view class= "photo1">
< image bindtap= "previewImage" data-list= "{{listData.photo}}" data-src= "{{baseUrl+item}}" class= "ping" src= "{{baseUrl+item}}" / >
view >
block >
js代码:

previewImage: function (event) { var src = event.currentTarget.dataset.src; //获取data-src

var imgList = event.currentTarget.dataset.list; //获取data-list
var baseurl = getApp().globalData.baseUrl;
var imgLists = [];
for( var i= 0;i<=imgList.length;i++){
imgLists.push(baseurl+imgList[i]);
}
console.log(imgLists);
//图片预览
wx.previewImage({
current: src, // 当前显示图片的http链接
urls: imgLists // 需要预览的图片http链接列表
})
},

你可能感兴趣的:(微信小程序)