相关疑难解决方法(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万
查看次数

参数“action”和“action”的类型在 Angular ngrx 商店项目中不兼容

我正在使用 Angular 创建我的第一个 NGRX 项目,并遵循本教程(请在此处找到所有文件代码)。

当我在 app.mdule.ts 中声明减速器时,我遇到了这个编译错误。

Type '(state: Tutorial[] | undefined, action: Actions) => Tutorial[]' is not assignable to type 'ActionReducer<Tutorial[], Action>'.
  Types of parameters 'action' and 'action' are incompatible.
    Type 'Action' is not assignable to type 'Actions'.
      Property 'payload' is missing in type 'Action' but required in type 'RemoveTutorial'.
22       **tutorial: reducer**
         ~~~~~~~~
  src/app/actions/tutorial.actions.ts:20:17
    20     constructor(public payload: Tutorial) { }
                       ~~~~~~~~~~~~~~~~~~~~~~~~
    'payload' is declared here.
Run Code Online (Sandbox Code Playgroud)
 imports: [
    BrowserModule,
    AppRoutingModule,
    StoreModule.forRoot({
      tutorial: reducer ///this line is …
Run Code Online (Sandbox Code Playgroud)

web typescript ngrx angular ngrx-store

3
推荐指数
1
解决办法
2394
查看次数

标签 统计

angular ×2

typescript ×2

javascript ×1

ngrx ×1

ngrx-store ×1

web ×1