gpt4 book ai didi

angular - SafeValue 必须使用 [property]=binding :

转载 作者:太空狗 更新时间:2023-10-29 17:00:16 26 4
gpt4 key购买 nike

我的输入中出现以下错误:

SafeValue must use [property]=binding: http://www.myurl.com (see http://g.co/ng/security#xss)

我在我的组件中做了:

this.myInputURL = this.sanitizer.bypassSecurityTrustUrl('http://www.myurl.com');

在我的模板中:

Share URL: <md-input [value]="myInputURL" type="text"></md-input>

怎么了?

最佳答案

改变这个

this.sanitizer.bypassSecurityTrustUrl('http://www.myurl.com');

this.sanitizer.bypassSecurityTrustResourceUrl('http://www.myurl.com');

两种选择的区别

绕过SecurityTrustUrl

Bypass security and trust the given value to be a safe style URL, i.e. a value that can be used in hyperlinks or <img src>. source angular.io

绕过SecurityTrustResourceUrl

Bypass security and trust the given value to be a safe resource URL, i.e. a location that may be used to load executable code from, like <script src>, or <iframe src>. source angular.io

关于angular - SafeValue 必须使用 [property]=binding :,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/39517394/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com