![](/img/trans.png)
[英]gMarker.key undefined and it is REQUIRED!! error in angular and google maps app
[英]Angular ESLint Error Parameter key required
我正在尝试使用以下 Angular 代码下载文件,但我一直在获取需要的参数“key”
const headerValues = new HttpHeaders({ 'Content-Type': contentType!, 'Accept': contentType! });
this.http
.get(`${this.resourceUrl}/${id}/download`, { headers: headerValues })
.subscribe(data => {
const blob = new Blob([data as BlobPart], { type: contentType });
const downloadUrl = window.URL.createObjectURL(blob);
window.open(downloadUrl);
console.log('Alert :: Done ');
}, (error) => {
console.log('Alert :: error: ' + error);
}, () => {
console.log("this is the finally block");
});
它不断打印警报::标签错误错误:需要参数“key”。 找不到任何相关内容。 这个错误是由 TranslateService 抛出的,但我不知道为什么
我找到了问题的解决方案。 默认 responseType 是 blob | 不明确的。 在 this.http.get() 选项参数中添加 blob responseType 解决了该问题。
this.http.get(`${this.resourceUrl}/${id}/download`, { headers, responseType: 'blob' }).subscribe((res) => {
const file = new Blob([res as BlobPart], {
type: contentType,
});
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.