我对此感到厌倦,请帮忙
function fileProperties(image){
image.properties.getImagePropertiesAsync().then(function (chiTiet) {
var imgWidth = chiTiet.width;
var imgHeight = chiTiet.height;
var imgBlob = URL.createObjectURL(image, { oneTimeOnly: true });
var data = imgWidth + imgHeight + imgBlob;
return data;
});
}
这不行。我如何返回var数据?
答案 0 :(得分:0)
function fileProperties(image){
return image.properties.getImagePropertiesAsync().then(function (chiTiet) {
var imgWidth = chiTiet.width;
var imgHeight = chiTiet.height;
var imgBlob = URL.createObjectURL(image, { oneTimeOnly: true });
var data = imgWidth + imgHeight + imgBlob;
return {
width: imgWidth,
height: imgHeight,
blob: imgBlob
};
});
}
在您的代码中使用它:
fileProperties(myImage).then(function(properties) {
console.log('Image width: ', properties.width);
console.log('Image height: ', properties.height);
console.log('Image blob: ', properties.blob);
});