无法访问Javascript对象属性

时间:2013-08-21 20:45:04

标签: javascript object properties

我的反对意见如下:

Object {mime: "image/png", ts: 1372704010, read: 1, write: 1, size: 452343…}
baseUrl: "http://davosovo/images/"
date: "1 Jul 2013 20:40"
dim: "960x400"
hash: "l1_YXBwc1xtb2plLXR2b3JiYS5wbmc"
height: "400"
mime: "image/png"
name: "moje-tvorba.png"
path: "images\apps\moje-tvorba.png"
phash: "l1_YXBwcw"
read: 1
size: 452343
tmb: "http://davosovo/images/.tmb/l1_YXBwc1xtb2plLXR2b3JiYS5wbmc1372704010.png"
ts: 1372704010
url: "http://davosovo/images/apps/moje-tvorba.png"
width: "960"
write: 1

我想要path属性。但它写信给我undefined我试过这样循环:

for (var key in file) {
console.log(key + ':' + file[key]);
}

它给了我这个:

mime:image/png
ts:1372704010
read:1
write:1
size:452343
hash:l1_YXBwc1xtb2plLXR2b3JiYS5wbmc
name:moje-tvorba.png
phash:l1_YXBwcw
date:1 Jul 2013 20:40
tmb:l1_YXBwc1xtb2plLXR2b3JiYS5wbmc1372704010.png

怎么了?

var elfinder = function(callback) {
            jQuery('<div />').dialogelfinder({
                url : '<?= SystemInfo::getDomainUrl() ?>/modules/elrte/php/connector.php',
                lang : '<?= $lang ?>',
                allowShortcuts : false,
                handlers : {
                    select : function (event, elfinderInstance) {
                        var selected = event.data.selected;

                        if (selected.length) {
                            var file = elfinderInstance.file(selected[0]);
                            console.log(file);
                            for (var key in file) {
                                console.log(key + ':' + file[key]);
                            }
                        }
                    },
                    dblclick: function(event, elfinderInstance) {

                    }
                },
                getFileCallback: callback // pass callback to file manager
            });
        }

0 个答案:

没有答案