更新img标签的src属性并不反映DOM

时间:2018-01-05 05:36:48

标签: javascript jquery html angularjs

我正在更新图片标记的src属性

<img src="assets/images/dummy.jpg" alt="" class="rounded-circle" id="logo-upload">

上面是带有虚拟src值的图像标签

我正在使用文件上传,文件上传后我分配了img标签的src和文件blob数据

   this.uploader.onAfterAddingFile = (fileItem) => {
      this.filePreviewPath  = this.sanitizer.bypassSecurityTrustUrl((window.URL.createObjectURL(fileItem._file)));
      let content:any= document.getElementById("logo-upload");
      content.src=this.filePreviewPath.changingThisBreaksApplicationSecurity;
      console.log(content);
    }

当我在控制台中检查时,我感觉像是

<img _ngcontent-c5 alt class=​"rounded-circle" id=​"logo-upload" src=​"blob:​http:​/​/​localhost:​4200/​1b569f92-3873-4cd9-b456-e7652c92dd4a">​

但是之后在DOM中它没有得到反映,它与虚拟图像相同

enter image description here

任何帮助都将不胜感激。

0 个答案:

没有答案
相关问题