gpt4 book ai didi

angular - 资源 URL 上下文中使用的不安全值 Angular 错误

转载 作者:太空狗 更新时间:2023-10-29 18:18:31 25 4
gpt4 key购买 nike

大家好,我想展示一个动态 pdf。起初它向我显示 CORS 错误。我使用 DOM Sanitizer 解决了这个问题。现在它向我显示不安全的网址。感谢任何帮助。

HTML 代码:

  <iframe src="{{Url}}"></iframe>

TS代码:这里pdfSrc存放的是动态生成的pdf路径;

 this.pdfSrc = 'http://192.168.1.183/' + this.pdfPath;
this.Url = this.sanitizer.bypassSecurityTrustUrl(this.pdfSrc);

最佳答案

最终得到的解决方案只是更改了 HTML 部分和 TS 部分,如下所示

<iframe [src]='Url' width="100%" height="1000px"></iframe>

constructor(private sanitizer:DomSanitizer){}

this.Url = this.sanitizer.bypassSecurityTrustResourceUrl(this.pdfSrc);

关于angular - 资源 URL 上下文中使用的不安全值 Angular 错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/51297198/

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