如何在函数WinJS中返回var

时间:2014-10-21 20:19:56

标签: jquery visual-studio-2013 winjs

我对此感到厌倦,请帮忙

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数据?

1 个答案:

答案 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);
});