AgGrid http.get 没有按预期返回 .json 数据

问题描述 投票:0回答:0

我无法使用 AgGrid 社区版获取 .json 数据。该文件驻留在网络服务器上,但它只是挂起。

//These two works as expected
this.rowData$ = this.http
  .get<any[]>('https://www.ag-grid.com/example-assets/row-data.json');
this.http.get('https://www.ag-grid.com/example-assets/row-data.json').subscribe(data => {
  console.log(data.toString);
})
//For some reason exact same .json page on another location does not work
this.http.get('https://localhost/row-data.json').subscribe(data => {
  console.log(data.toString);
})    

只要我从 ag-grid.com 获取 .json 数据,一切正常。如果我尝试从本地主机或任何其他打开的网页域获取完全相同的 .json 数据,则 http.get 不再检索数据。它只是挂起(没有返回错误)。 关于如何处理这个问题有什么建议吗?

在我看来,AgGrid 应该能够检索驻留在另一台服务器上的 .json 数据,使用这个库时没有问题吗? 从'@angular/common/http'导入{HttpClient};

json angular ag-grid
© www.soinside.com 2019 - 2024. All rights reserved.