我试图从后端服务器检索数据,但我得到以下错误:类型'订阅'缺少类型'HomeData'中的以下属性:aSes、聚合器更改、公告、beacon公告和11个以上。
我正在使用以下服务
export class HomeService {
constructor(private http: HttpClient) { }
getData(): Observable<HomeData>{
return this.http.get<HomeData>('https://bgpie.net/api/rrc/00');
}
}
以及以下界面:
export interface HomeData{
aSes: number;
aggregatorChanges: number;
announces: number;
beaconAnnouncements: number;
beaconSequences: number;
beaconWithdrawals: number;
cPs: number;
containingLoops: number;
containsAggregator: number;
moreThanOneAsOrigin: number;
prefixes: number;
prefixv4: number;
prefixv6: number;
sequences: number;
withdraws: number;
}
我在组件中调用getData(),如下所示:
export class HomeComponent implements OnInit {
elements!: HomeData;
constructor(private http: HttpClient,
private homeService: HomeService) {
}
ngOnInit(): void {
this.elements = this.homeService.getData().subscribe((data: HomeData) => {this.elements = data; });
}
我把所有这些都放在我的html模板中
<ul>
<li *ngFor = "let element of elements">
Total number of Sequences: <b>{{element.sequences}}</b>
<br>Distinct Prefixes involved in Sequences: <b>{{element.prefixes}}</b>
<br>BGP Updates involved in Sequences: /// (Announces: <b>{{element.announces}}</b>, Withdrawals: <b>{{element.withdraws}}</b>)
<br>Total number of BGP Updates collected by RRC00 in 2019: /// (Announces: ///, Withdraws: ///)
<br>Percentage of BGP Updates belonging to Sequences: /// (Announces: ///, Withdrawals: ///)
<br>Distinct Collctor Peers (CPs) that observed at least a Sequences: <b>{{element.cPs}}</b>
<br>Distinct ASes originating the prefexes involved in the Sequences: <b>{{element.aSes}}</b>
<br>Number of AB-BA Sequences (whose AS-path contains pattern xAyBz and x'By'Az'): <b>{{element.containingLoops}}</b>
<br>Sequences that are originated by an IPv4 Prefix: <b>{{element.prefixv4}}</b>
<br>Sequences that are originated by an IPv6 Prefix: <b>{{element.prefixv6}}</b>
<br>Sequences whose prefix is announced by more than one AS: <b>{{element.moreThanOneAsOrigin}}</b>
<br>Sequences that contain at least one announcement with the BGP Path Attribute Aggregator set: <b>{{element.containsAggregator}}</b>
<br>Sequences that contain at least two announcement with different values of the BGP Path Attribute Aggregator: <b>{{element.aggregatorChanges}}</b>
<br>Sequences originated by a known beacon prefix: <b>{{element.beaconSequences}}</b>
<br>BGP Updates originated by a known beacon prefix: <b>{{element.beaconAnnouncements + element.beaconWithdrawals}}</b> (Announcements: {{element.beaconAnnouncements}}, Withdrawals: {{element.beaconWithdrawals}})
<br>Percentage of BGP Updates originated by a known beacon prefix: /// (Announcements: ///, Withdrawals: ///)
</li>
</ul>
您正在将订阅分配给变量元素
。相反,它应该是以下内容
js prettyprint-override">ngOnInit(): void {
this.homeService.getData().subscribe(
(data: HomeData) => { this.elements = data; },
(error: any) => { /* handle error */ }
);
}
我有以下定义: 伊鲁特: IRoutesConfig: 以及我的路由配置,然后将其传递给类以进一步增强 我正在测试登录功能组件: 这是一个新的项目设置,还没有为登录道具定义任何内容。因此,它当前为空,稍后将进行扩展,内容也是如此,因为我们目前正在设置routes体系结构。 VSCode在中的"组件"上给了我以下提示: 我当然不是声明类型、道具和钥匙。 最后,路由配置将被提供给RouteManage
1. HttpTransfer无法解析为类型 2.来自AndroidHttp类型的方法newCompartbleTransport()是指缺少的HttpTransment类型 我在libs文件夹中添加了以下jar文件: google-api-client-android-1.18.0-rc.jar google-api-services-drive-v2-rev1-1.7.2-beta.jar g
问题内容: 简单的问题。如何初始化这个结构?我想做这样的事情: 预计我会遇到错误: 当然,我可以创建一个单独的结构B并通过以下方式对其进行初始化: 但是它没有第一种方法有用。有没有初始化匿名结构的捷径? 问题答案: 该可转让规则是宽容的,这导致另一种可能性,你可以保留的原始定义匿名类型写入,同时允许该类型的短复合文字。如果您确实坚持使用该字段的匿名类型,那么我可能会写类似以下内容: 操场 输出量
我只是在试着学OAuth。我写了一些代码来测试它。当我提交请求时,我得到{“error”:“invalid_request”,“error_description”:“missing grant type”} 邮递员的错误。 这是我寄给邮递员的东西:
我有一个抽象类的具体对象。 我在抽象类和子类上使用注释,但JSON输出看起来不正确,而且我一直在反序列化上遇到异常。 我还在学习杰克逊,不幸的是,很多关于这个主题的教程已经过时了。 以下是底部有我的对象映射器的类: 抽象类: 混凝土等级: Objectmapper块: 输出JSON: 例外: 其他答案(例如多态类型的Jackson反序列化)建议使用方法,但根据我阅读的教程,这应该没有必要。 不知道
我已经在项目构建路径中导入了apachepoi的所有jar文件,但我仍然收到错误“类型XSSFWorkbook中的方法getSheetAt(int)引用了缺少的类型XSSFSheet” 我使用版本- poi-bin-4.1.2-20200217 代码: