收到错误
f.ngOnChanges 不是函数
仅当我的 tsconfig.json 文件设置为以 es5 为目标时才会出现此问题,但是如果我的目标是 es6,则一切都按预期工作。
如果我的目标是 es5,有谁知道如何让 ngOnChange 工作?
import {Component, ViewChild, Type, Input, Output, OnInit,OnChanges, ElementRef, EventEmitter, SimpleChanges} from '@angular/core';
@Component({
selector: "form",
styleUrls:['./crop.form.component.css'],
templateUrl: './crop.form.component.html',
})
export class CropFormComponent extends Type {
@Input() imageFile: any;
@Output() showUploadModal = new EventEmitter;
size: string;
// imageCropped: boolean; // imageNotCropped: boolean;
//Cropper 2 data
data:any;
constructor() { }
ngOnChanges(changes: SimpleChanges): void{
}
}
tsconfig.json
{
"compileOnSave": false,
"compilerOptions": {
"outDir": "./dist/out-tsc",
"sourceMap": true,
"declaration": false,
"moduleResolution": "node",
"emitDecoratorMetadata": true,
"experimentalDecorators": true,
"target": "es5",
"typeRoots": [
"node_modules/@types"
],
"lib": [
"es2017",
"dom"
]
}
}