1.判断是否是ios设备
var ios = window.__wxjs_is_wkwebview;
if(ios){//判断是否是ios
that.iosPreview(localIds);
}else {
localIds.forEach(item => {
that.imgList.push(item);
})
}
2.采用异步请求的方式,在methods里面定义方法:
async iosPreview(localIds){
for(var i = 0; i < localIds.length; i++) {
await this.readImage(localIds[i]);
}
},
readImage(item){
let _this = this;
return new Promise((resolve, reject) => {
wx.getLocalImgData({
localId: item,
success: function(res) {
let localData = res.localData;
localData = localData.replace('jgp', 'jpeg');
_this.imgList.push(localData);
resolve('done!');
},
fail: function() {
}
})
})
}