我正在添加带有标签的新 HTML 页面。
<object *ngIf='displayUrl' resize-to-tile type="text/html"
[attr.data]="displayUrl" >
</object>
this.displayUrl = this.sanitizer.bypassSecurityTrustResourceUrl(this.parameters.items.data.params.items[0].value);
但是我有下一个错误:
SafeValue must use [property]=binding: undefined (see http://g.co/ng/security#xss) SafeValue must use [property]=binding: undefined (see http://g.co/ng/security#xss)
我该如何解决?
最佳答案
删除 attr.
[data]="displayUrl" >
从 bypassSecurityXxx
返回的值被包裹在一个类中。
属性绑定(bind)仅支持字符串值,因此 [attr.xxx]
破坏 sanitizer 。
<object>
元素有一个 data
属性(property),因此 attr.
无论如何都不需要https://developer.mozilla.org/en-US/docs/Web/API/HTMLObjectElement
关于javascript - Angular 应用程序中 <object> 标签的安全错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/45350082/