这个想法是在角度端嵌入一个 pdf 文件,该文件由节点快递服务器以 blob 形式返回。
之后我得到图像并创建了一个 URL
const file = new Blob([this.data], { type: 'application/pdf' });
this.fileUrl = URL.createObjectURL(file);
this.protectedUrl = this.sanitizer.bypassSecurityTrustUrl(this.fileUrl);
然后在我在 html 中使用它之后
<object ng-show="content" data="{{protectedUrl}}" type="application/pdf" style="width: 100%; height: 400px;"></object>