ng build --prod时P-fileupload中的角度错误

问题描述 投票:1回答:2

在我的Angular项目中,当我尝试运行ng build --prod时,我在p-fileUploadprimeng中遇到了这个问题:

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的错误

angular primeng
2个回答
0
投票

出于某种原因,如果我删除onBeforeUpload(event) {}方法,它可以正常工作和构建


-2
投票

尝试使用此命令构建:

ng build --prod --aot=false;
© www.soinside.com 2019 - 2024. All rights reserved.