相关疑难解决方法(0)

属性'...'没有初始化程序,并且在构造函数中没有明确赋值

在我的Angular应用程序中,我有一个组件:

import { MakeService } from './../../services/make.service';
import { Component, OnInit } from '@angular/core';

@Component({
  selector: 'app-vehicle-form',
  templateUrl: './vehicle-form.component.html',
  styleUrls: ['./vehicle-form.component.css']
})
export class VehicleFormComponent implements OnInit {
  makes: any[];
  vehicle = {};

  constructor(private makeService: MakeService) { }

  ngOnInit() {
    this.makeService.getMakes().subscribe(makes => { this.makes = makes
      console.log("MAKES", this.makes);
    });
  }

  onMakeChange(){
    console.log("VEHICLE", this.vehicle);
  }
}
Run Code Online (Sandbox Code Playgroud)

但在"制造"属性中我有一个错误.我不知道该怎么做...

错误

javascript typescript angular

45
推荐指数
26
解决办法
2万
查看次数

标签 统计

angular ×1

javascript ×1

typescript ×1