<swiper indicator-dots="{{indicatorDots}}" autoplay="{{autoplay}}" interval="{{interval}}" duration="{{duration}}" indicator-active-color="{{indicatorActiveColor}}">
<block wx:for="{{goodsDetail.cg_goods_pic}}" wx:key="{{key}}">
<swiper-item>
<image bindtap='previewImg' src="{{item}}" class="slide-image" width="355" height="150" />
</swiper-item>
</block>
</swiper>
js:
//点击图片放大
previewImg: function (e) {
console.log(e.currentTarget.dataset.index);
var index = e.currentTarget.dataset.index; //当前图片的下标
var goodsDetail = this.data.goodsDetail.cg_goods_pic; 加粗的是上面 for 循环的
wx.previewImage({
current: goodsDetail[index], //当前图片的地址 是哪一张图片
urls: goodsDetail, //所有要预览的图片的地址集合 数组形式
success: function (res) {
console.log(“成功”)
},
fail: function (res) {
console.log(“失败”)
},
complete: function (res) { },
})
},