这是wxml代码
<view class="section"> <view class="flex-wrp" style="flex-direction:row;"> <view class="flex-item loadpic" bindtap='chooseImage'>点击添加图片 </view> <view class='showPic'> <view wx:for="{{imagesList}}" wx:for-item="image" wx:key="index" class="previewimg"> <image class='image' src="{{image}}" data-src="{{image}}" bindtap="previewImage"></image> </view> </view></view></view> |
这是js代码
chooseImage: function(){ var that = this; wx.chooseImage({ count: 1, sizeType: ['original', 'compressed'], sourceType: ['album', 'camera'], success: function(res) { // console.log(res) wx.showToast({ title: '正在上传', icon: 'loading', mask: true, duration: 1000 }) var tempFilePaths = res.tempFilePaths that.setData({ imageList: tempFilePaths }) console.log(tempFilePaths) } }) }, previewImage:function(e){ var current = e.target.dataset.src; wx.previewImage({ urls:this.data.imageList, current: current, success: function(e){ console.log("预览成功") } }) }, |
选择图片正常,还可以打印出 url ;["http://tmp/wx5958ef33e1aeaf56.o6zAJs7eDvKwg0bUs9EW….T8JsDPzqZqIydaf9e5582f28c4ff41f527fa53d60a5f.jpg"]
然后就是预览不出
找了很多参考还是没解决啊

别逗了。。wxml里是
imagesList,js里是imageList,能显示就邪了。。。用手机试试,这个地址是电脑上模拟的,和微信中不一样
手机上的地址打印下看看
好像是选择的图片不能使用预览,下载的临时文件可以
预览图片是网络图片吗?