我有以下功能: -
uploadPhoto() {
var nativeElement: HTMLInputElement = this.fileInput.nativeElement;
this.photoService.upload(this.vehicleId, nativeElement.files[0])
.subscribe(x => console.log(x));
}
Run Code Online (Sandbox Code Playgroud)
但是在nativeElement.files [0]上,我收到了一个打字稿错误,"对象可能是'null'".有人可以帮我解决这个问题吗?
我试图将nativeElement声明为null值,但是没有成功.
谢谢你的帮助和时间.