在我的Angular项目中,当我尝试运行ng build --prod
时,我在primeng的p-fileUpload
中遇到了此问题:
都不匹配
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
答案 0 :(得分:0)
出于某种原因,如果我删除了onBeforeUpload(event) {}
方法,它可以正常构建
答案 1 :(得分:-2)
尝试使用此命令构建:
ng build --prod --aot=false;