当我通过 DomSanitizer 传递远程 url 时,http://localhost:4200会作为 url 的前缀,结果是 404。
GET http://localhost:4200/.cs.uic.edu/~i101/SoundFiles/Fanfare60.wav 404 (Not Found)
原文网址:https ://www2.cs.uic.edu/~i101/SoundFiles/Fanfare60.wav
我的代码:
constructor(private sanitizer: DomSanitizer) {}
public getSantizeUrl(url: string) {
return this.sanitizer.bypassSecurityTrustResourceUrl(url);
}
还有我的模板:
<audio #player style="width: 100%" controls="controls" [src]="getSantizeUrl(chunk.value)" >
</audio>
有什么我想念的吗?为什么是前缀?FWIW bypassSecurityTrustUrl(url) 具有相同的效果。
谢谢