即使对象上的console.log显示属性值,对象的属性也未定义

时间:2019-05-16 12:31:01

标签: javascript angular typescript blob

我有一个对象dmDocumentLinks,当我将其打印到控制台时,它会显示具有属性值的对象。

console.log(this.dmDocumentLinks); enter image description here 返回

createdAt: "2019-05-16T12:09:52"
createdBy: "admin"
documentBlob: "UEsDBBQAAAAIAEZisE5LVVb02AAAAD0CAAALABQAX3JlbHMvLnJlbHMBABAAAAAAAAAAAAAAAAAAAAAAAK2STUsDQQyG7/0VQ+7dbCuISHd7EaE3kfoDwkx2d2jng0zU+u8dRNGFUgQ95s2bh+eQzfYUjuaFpfgUO1g1LRiONjkfxw6e9vfLG9j2i80jH0lrpUw+F1NvYulgUs23iMVOHKg0KXOsmyFJIK2jjJjJHmhkXLftNcpPBvQzptm5DmTnVmD2b5n/xsbASo6U0CbhZZZ6Leq5VDjJyNqBS/ahxuWj0VQy4Hmh9e+F0jB4y3fJPgeOes6LT8rRsbusRDlfMrr6T6N541vmNYlD9xl/2eDsC/rFO1BLAwQUAAAACABGYrBOBCHWFboAAAAbAQAAEQAUAGRvY1Byb3BzL2NvcmUueG1sAQAQAAAAAAAAAAAAAAAAAAAAAABtjk1rhEAQRO/+Cpm7tm4gBFn1llMWAklgr0Pb0WGdD6Y7GX9+JrKYS45FvXrUedzsWn5TZONdr9q6USU59JNxc68+3p+rJzUOxRlDhz7Sa/SBohjiMu8cdxh6tYiEDoBxIau5zoTL5aePVkuOcYag8aZnglPTPIIl0ZMWDb/CKhxGdVdOeCjDV1x3wYRAK1lywtDWLfyxQtHyv4O9OciNzUGllOr0sHP5UQvXy8vbfr4yjkU7JAVD8QNQSwMEFAAAAAgARmKwTveOlC+MAAAA1wAAABAAFABkb2NQcm9wcy9hcHAueG1sAQAQAAAAAAAAAAAAAAAAAAAAAACdzs0KwjAQBOB7nyLk3qZ6ECn9uRTPHqr3kmzagNkNyVrq2xsRfACPwzAf0w67f4gNYnKEnTxUtRSAmozDpZO36VKe5dAX7TVSgMgOksgDTJ1cmUO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BLAQI+ABQAAAAIAEZisE75Lv+47gAAAJcDAAAcAAAAAAAAAAAAAAAAAE0WAAB3b3JkL19yZWxzL2RvY3VtZW50LnhtbC5yZWxzUEsBAj4AFAAAAAgARmKwTlhc8cqnAQAAvwcAABMAAAAAAAAAAAAAAAAAiRcAAFtDb250ZW50X1R5cGVzXS54bWxQSwUGAAAAAAwADAD7AgAAdRkAAAAA"
documentBlobContentType: "application/vnd.openxmlformats-officedocument.wordprocessingml.document"
documentFileUrl: undefined
documentName: "word"
fileName: undefined
filePath: "files/AJUKzxL.vnd.openxmlformats-officedocument.wordprocessingml.document"
id: 577601
updatedAt: "2019-05-16T12:19:16"
updatedBy: "admin"
uri: undefined
__proto__: Object

但是当我尝试访问对象的属性时,却无法定义

console.log(this.dmDocumentLinks.documentBlobContentType);

返回

undefined

该对象有一个Blob字段,可能是问题所在吗?

完整代码

 setFileData(event, entity, field, isImage) {
        if (event['srcElement'].files && event['srcElement'].files[0] && event['srcElement'].files[0].size !== undefined && event['srcElement'].files[0].size < 1024000) {
            if (event['srcElement'].files[0].size === 0) {
                const translatedAlert = this.translateService.instant('error.emptyFile');
                this.toastrService.warning(translatedAlert);
            } else {
                const returnObject = {
                    event: event,
                    entity: entity,
                    field: field,
                    isImage: isImage,
                    dmDocumentLinks: this.dmDocumentLinks
                };
               console.log(this.dmDocumentLinks);
               console.log(this.dmDocumentLinks.documentBlobContentType);
                this.documentLinksChanged.emit(returnObject);
            }
        } else {
            if(event['srcElement'].files[0]){
                const translatedAlert = this.translateService.instant('error.fileSize');
                this.toastrService.warning(translatedAlert);
            }
        }
    }
在HTML中的更改事件上调用

function setFileData(event, entity, field, isImage)

<div class="col-md-6">
    <div class="form-group">
        <label class="form-control-label" jhiTranslate="hcmGatewayApp.dmDocumentLinks.documentBlob"
               for="field_documentBlob">Document Blob</label>
        <div>
            <div *ngIf="dmDocumentLinks.documentBlob" class="form-text text-danger clearfix">
                <a class="pull-left"
                   (click)="openFile(dmDocumentLinks.documentBlobContentType, dmDocumentLinks.documentBlob)"
                   jhiTranslate="entity.action.open">open</a><br>
                <span class="pull-left">{{dmDocumentLinks.documentBlobContentType}}, {{byteSize(dmDocumentLinks.documentBlob)}}</span>
                <button type="button"
                        (click)="resetBlob();"
                        class="btn btn-secondary btn-xs pull-right">
                    <span class="fa fa-times"></span>
                </button>
            </div>
            <input type="file" id="file_documentBlob"
                   (change)="setFileData($event, dmDocumentLinks, 'documentBlob', false)"
                   jhiTranslate="entity.action.addblob"/>
        </div>
        <input type="hidden" class="form-control" name="documentBlob" id="field_documentBlob"
               [(ngModel)]="dmDocumentLinks.documentBlob" required/>
        <input type="hidden" class="form-control" name="documentBlobContentType"
               id="field_documentBlobContentType"
               [(ngModel)]="dmDocumentLinks.documentBlobContentType"/>
    </div>
</div>

3 个答案:

答案 0 :(得分:2)

看来documentBlobContentType属性是在console.log语句之后设置的。这就是console.log(this.dmDocumentLinks.documentBlobContentType)给出undefined的原因。

对于console.log(this.dmDocumentLinks),它在控制台中显示活动对象。仅当您单击箭头以展开属性列表时,才评估属性值。到那时,documentBlobContentType属性已经设置完毕,您可以在控制台中看到其值。

要在执行console.log语句时按原样显示对象,请将其转换为JSON字符串:

console.log(JSON.stringify(this.dmDocumentLinks));

您可以在Boris Sever的this article中找到有关如何对对象使用console.log的更多详细信息。

答案 1 :(得分:0)

  

尝试一下

var response = <any>(this.dmDocumentLinks);
console.log(response.documentBlobContentType);

答案 2 :(得分:0)

尝试使用类似的方法: console.log(this.dmDocumentLinks && this.dmDocumentLinks['documentBlobContentType']);