在我的Angular项目中,当我尝试运行ng build --prod
时,我在p-fileUpload
的primeng中遇到了这个问题:
media.component.html
(5,81):提供的参数与呼叫目标的任何签名都不匹配
但如果我使用没有ng build
的--prod
,它会正常构建。如果我使用ng serve
也一样。
这是代码:
<p-fileUpload mode="basic" #fileInput name="files" url="{{url}}" auto="auto" (onBeforeUpload)="onBeforeUpload($event)" chooseLabel="Allega file"
(onUpload)="onUpload($event)" (onProgress)="onProgress($event)" (onError)="onError($event)" multiple="multiple" (onBeforeSend)="onBeforeSend($event)"
accept="{{uploadAcceptedFormat}}" maxFileSize="{{maxUploadSize}}"></p-fileUpload>
这是方法:
onError(event: any) {
this.showProgressBar = false;
console.log(event);
this.openSnackBar('Upload fallito')
}
onBeforeSend(event) {
event.xhr.setRequestHeader('Authorization', 'Bearer ' + localStorage.getItem('token'));
this.showProgressBar = true;
}
onUpload(event) {
this.openSnackBar('Upload completato')
this.progressValue = 0;
this.showProgressBar = false;
this.reloadMedias();
}
onBeforeUpload(event) {}
onProgress(event) {
if (event.originalEvent.loaded !== 0) {
this.progressValue = (event.originalEvent.loaded / event.originalEvent.total) * 100;
}
}
像fileupload中的所有其他方法一样,我有1个事件,所以为什么这只给我带--prod
的错误
出于某种原因,如果我删除onBeforeUpload(event) {}
方法,它可以正常工作和构建
尝试使用此命令构建:
ng build --prod --aot=false;