WeChatウィジェットは新しいページでフルスクリーンで画像をプレビューします。
1768 ワード
wxml
wxss.imgList{
width: 100%;
}
.imgList .imgList-li{
width: 100%;
}
.imgList .imgList-li .img{
width: 400rpx;
height: 400rpx;
}
jsPage({
data: {
imgArr:[
'http://bpic.588ku.com/element_origin_min_pic/16/10/30/528aa13209e86d5d9839890967a6b9c1.jpg',
'http://bpic.588ku.com/element_origin_min_pic/16/10/30/54fcef525fa8f6037d180f3c26f3be65.jpg',
'http://bpic.588ku.com/element_origin_min_pic/16/10/30/62e3ca3a02dddb002eff00482078d194.jpg',
'http://bpic.588ku.com/element_origin_min_pic/16/10/31/c7167fcfb4ebcd12621c05b0c852e98e.jpg'
]
},
previewImg:function(e){
console.log(e.currentTarget.dataset.index);
var index = e.currentTarget.dataset.index;
var imgArr = this.data.imgArr;
wx.previewImage({
current: imgArr[index], //
urls: imgArr, //
success: function(res) {},
fail: function(res) {},
complete: function(res) {},
})
}
})
画像をクリックして拡大します。つまり、wx.previewimageの時に、onehideを触発します。プレビューが戻ったら、onshowを触発します。1). data preImgStatus: false
2). previewImage this.setData({preImgStatus: true})
3). onhide
if(this.data.preImgStatus == true) {
this.setData({ preImgStatus: false});
return;
}
// onhide ,onshow