如何解决使用 bypassSecurityTrustResourceUrl 是给 SafeValue 必须在结果中使用 [property]
我正在尝试使用 bypassSecurityTrustResourceUrl 解析图像,但在输出中我得到了
SafeValue must use [property]=binding: data:image/jpeg;base64,(actual data) (see http://g.co/ng/security#xss)
如下图所示
这是我的代码
loadImages(): void {
this.projectsDetailService.getById(this.param_id).
subscribe((data: any) => {
console.log("Step 1")
this.projectList = data;
for (var index in this.projectList) {
this.images = this.projectList[index].img;
this.objectURL = 'data:image/jpeg;base64,' + this.images;
this.thumbnail1 = this.sanitizer.bypassSecurityTrustResourceUrl(this.objectURL);
this.projectList[index].img = this.thumbnail1;
console.log("Data is "+this.thumbnail1);
}
}
);
}
解决方法
正如错误描述中提到的,你必须使用属性绑定的方式来摆脱这个错误。在此处查看 Günter Zöchbauer 的确切解决方案。 Safe value must use [property]=binding after bypass security with DomSanitizer
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。