Angular2 - 提供的参数与调用目标的任何签名都不匹配

Aja*_*jay 9 angular2-aot angular

import { Component, Input, OnChanges } from '@angular/core';

@Component({
  selector: 'image-display',
  templateUrl: './image-display.component.html'
})
export class ImageDisplayComponent implements OnChanges {
  @Input() image: File;
  @Input() imagePath?: string;

  private fileReader: FileReader;

  constructor() { }

  ngOnChanges() {
    if (this.image && this.fileReader) {
      this.fileReader.readAsDataURL(this.image);
    }
  }
}
Run Code Online (Sandbox Code Playgroud)

在使用AOT进行编译时得到以下错误:

PRINHYLTPAP0592:matata ajays$ ng build --prod --aot
/myApp/src/$$_gendir/app/image-uploader/image-display/image-display.component.ngfactory.ts (61,9): 
Supplied parameters do not match any signature of call target.
Run Code Online (Sandbox Code Playgroud)

Ped*_*nna 22

AOT强制您为每个方法调用通知每个必需参数.

在您的示例中,方法ngOnChanges()实际上应该是ngOnChanges(更改:SimpleChanges).