【问题标题】:Angular pdf display: SafeValue must use [property]=bindingAngular pdf 显示:SafeValue 必须使用 [property]=binding
【发布时间】:2019-07-03 06:02:41
【问题描述】:

我在尝试显示 pdf 时收到“SafeValue must use [property]=binding”错误/警告。我不知道为什么,因为我正在使用绑定。这是我的代码。

getSafeUrl() {
 return this.sanitizer.bypassSecurityTrustResourceUrl(this.pdfSrc)+"?bearer "+this.token;     
}

<iframe [src]="getSafeUrl()" frameborder="0" *ngIf="pdfSrc"></iframe>

【问题讨论】:

    标签: javascript angular


    【解决方案1】:

    使用bypassSecurityTrustHtml[innerHTML]

    return this.sanitizer.bypassSecurityTrustHtml(this.pdfSrc + "?bearer "+this.token);     
    
    <div [innerHTML]="getSafeUrl()"  *ngIf="pdfSrc"></div>
    

    【讨论】:

    • 这会打印出文本并且不显示 pdf
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2018-06-05
    • 2018-07-06
    • 1970-01-01
    • 2018-01-03
    • 2021-04-08
    • 2018-09-20
    相关资源
    最近更新 更多