Angular 如何将blob URL用作SVG图像标记的xlink:href属性
我需要在Angular 如何将blob URL用作SVG图像标记的xlink:href属性,angular,typescript,svg,Angular,Typescript,Svg,我需要在svg-标记内显示simpile图像。图像可通过如下“blob:http://localhost:4200/8e011a50-95a6-4063-baeb-e760b6fd98a2”。blob URL在正常的img上工作,没有问题 但在svgimage标记中,由于以下原因而失败: SafeValue必须使用[property]=绑定:blob:http://localhost:4200/4baf011f-a23d-45a7-9be2-3a6a9109ffda(参见) 模板如下所示:
svg
-标记内显示simpile图像。图像可通过如下“blob:http://localhost:4200/8e011a50-95a6-4063-baeb-e760b6fd98a2”。blob URL在正常的img
上工作,没有问题
但在svgimage
标记中,由于以下原因而失败:
- SafeValue必须使用[property]=绑定:blob:http://localhost:4200/4baf011f-a23d-45a7-9be2-3a6a9109ffda(参见)
....
<svg ...>
<image [attr.xlink:href]="domSanitizer.bypassSecurityTrustUrl(blobstoreUrl)"></image>
...
</svg>
....
在其他帖子中,我发现绕过securitytrustresourceURL
应该修复它,但它没有
我想问题是
[attr.xlink:href]
是属性绑定,但是错误告诉我们我必须使用[property]=binding
。但是如何解决这个问题呢?你找到解决这个问题的方法了吗?遇到同样的问题
@Component({...})
export class MyComponent {
blobstoreUrl: string
constructor(public domSanitizer: DomSanitizer) { }
ngOnInit() {
// do some calculation
this.blobstoreUrl = "blob:http://localhost:4200/8e011a50-95a6-4063-baeb-e760b6fd98a2"
}
}