gpt4 book ai didi

angular - 错误消息 : Member 'makes' implicitly has an 'any' type

转载 作者:行者123 更新时间:2023-12-05 06:35:41 25 4
gpt4 key购买 nike

我收到一条错误消息:成员“makes”隐式具有“任何”类型。

export class VehicleFormComponent implements OnInit {
makes;
constructor(private makeService:MakeService) { }
ngOnInit() {
this.makeService.getMakes().subscribe(makes=>{
this.makes = makes
console.log("MAKES",this.makes);
});

编辑:

如果我添加 makes:any[]; 而不是 make:any 我会收到以下错误:

Property 'makes' has no initializer and is not definitely assigned in the constructor. at: '10,3' source: 'ts' code: '2564'

最佳答案

用特定类型声明你的变量 make 并初始化它

makes:any = [];

关于angular - 错误消息 : Member 'makes' implicitly has an 'any' type,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/49612279/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com