html
<input type="file" #Image accept="image/*"
(change)="handleFileInput($event.target.files)">
Run Code Online (Sandbox Code Playgroud)
.ts 文件
public handleFileInput(files: FileList) {
this.fileToUpload = files.item(0);
console.log(this.fileToUpload);
}
Run Code Online (Sandbox Code Playgroud)
我收到一个 html 错误:
类型“EventTarget”上不存在属性“文件”