var data = {};
var photos = new Array();
var photosList = $api.domAll(".uploadPhotos");//选择所有图片
for (var ii = 0; ii
per = $api.attr(photosList[ii], 'src');
trans = api.require('trans');//转成base64的调用函数
trans.decodeImgToBase64({
imgPath : per//图片路径
}, function(ret, err) {
if (ret.status) {
var dataUrl = 'data:image/png;base64,' + ret.base64Str;
photos[ii] = dataUrl;
alert(photo[ii]);//有多少张图片就弹出几次base64数据
return photos[ii];
} else {
api.alert({
msg : err.msg
});
}
return photos[ii];
});
}
data['photos'] = photos;alert(photos);
alert(photos.length);//弹出 0