HTML页面:
[style.background-image]="bgpictrue"
component.ts页面:
import{ DomSanitizer }from'@angular/platform-browser';
constructor(
privatesanitizer: DomSanitizer
){}
this.bgpictrue=this.sanitizer.bypassSecurityTrustStyle("url('"+image_str+"')");
网友评论