在開發微信小程序時,開發人員會參考着小程序api來開發小程序,但有的時候根據情況不同很容易出現bug,以下是我在開發小程序時出現的各種bug,在開發時有需要預覽圖片。
1.xml
1 <view class='detail_img'> 2 <view class='view_img' wx:for="{{imglist}}" wx:for-item="image"> 3 <image src='{{image}}' data-src="{{image}}" bindtap="previewImage"></image> 4 </view> 5 <view style='clear:both;'></view> 6 </view>
2.js
data: {
imglist:['圖片鏈接','圖片鏈接','圖片鏈接']
},
/**
* 預覽圖片
*/
previewImage: function (e) {
var current = e.target.dataset.src;
wx.previewImage({
current: current, // 當前顯示圖片的http鏈接
urls: this.data.imglist // 需要預覽的圖片http鏈接列表
})
} ,
