获取 'caller'、'callee' 和 'arguments' 属性可能无法在严格模式函数上访问以在 Function.invokeGetter 中调用它们 [英] Getting 'caller', 'callee', and 'arguments' properties may not be accessed on strict mode functions for calls to them at Function.invokeGetter
问题描述
我在 Angular 8 中使用 FormData 时出错.错误是'caller'、'callee' 和 'arguments' 属性可能无法在严格模式函数或在 Function.invokeGetter 调用它们的参数对象上访问"和使用此错误获取空数组.
I have error with FormData in Angular 8. Error is "'caller', 'callee', and 'arguments' properties may not be accessed on strict mode functions or the arguments objects for calls to them at Function.invokeGetter" and get Empty array with this error.
不知道是语法错误还是逻辑错误
I wondered if I have syntax error or logic error
我的html
<form #f="ngForm" >
<img *ngFor='let url of PhotoModels' [src]="url" height="200">
<br/>
<input type='file' #fileInput (change)="onSelectFile($event)" multiple>
<button (click)="submit(f)" class="btn btn-success">save</button>
</form>
我的组件
public PhotoModels = [];
@ViewChild('fileInput', { static: false }) fileInput:ElementRef
submit(f) {
var PhotosElement: HTMLInputElement= this.fileInput.nativeElement
this.PhotosService.Createphotos(PhotosElement.files)
}
我的服务
Createphotos(Photo) {
let formData = new FormData();
formData.forEach
for(let i =0; i < Photo.length; i++){
formData.append("Photos", Photo[i]);
}
console.log(formData)
}
推荐答案
不能直接查看formdata,要获取所有文件列表,需要使用getAll函数里面formdata 对象,如下所示.
You cannot directly inspect formdata, For getting all files list, you need to use getAll function inside formdata object , like below.
我可以运行您附加的代码,但我在控制台中没有看到任何错误.希望这对您有所帮助.如果您遇到问题,请告诉我.
I'm able to run the code you attached, I didn't see any error in my console. Hope this helps you, Let me know still if you are facing an issue.
这篇关于获取 'caller'、'callee' 和 'arguments' 属性可能无法在严格模式函数上访问以在 Function.invokeGetter 中调用它们的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!