简体   繁体   English

<p-fileUpload>在文件上传时更改 PrimeNG 上的图标

[英]<p-fileUpload> Change icon on PrimeNG on file upload

Is it possible to change the icon on choose button on file upload ?是否可以更改文件上传时选择按钮上的图标? In my case it is always "+".就我而言,它始终是“+”。

<p-fileUpload 
  class="btn-primary"
  auto="true"
  mode="basic"
  name="demo[]" 
  chooseLabel="Upload"
  [url]="apiImageLocation" 
  accept="image/*"
  maxFileSize="2000000" 
  (onUpload)="onUploadImageSuccess($event)" 
  (onError)="onUploadImageError($event)">
</p-fileUpload>

You can override font awesome plus icon in the CSS of your component :您可以在组件的 CSS 中覆盖 font awesome plus图标:

::ng-deep .ui-fileupload-choose .fa-plus::before {
  content: "\F0A6";
}

See StackBlitzStackBlitz

::ng-deep .ui-fileupload-choose .fa-plus::before {
  content: "\F0A6";
   background: red;
}

::ng-deep .ui-button .fa-upload::before{
  background: red;
   content: "\F0A6";

}

::ng-deep .ui-button .fa-close::before{
  background: red;
   content: "\F0A6";

}


but new primeng pi-upload,pi-times

You can now set the icons with attributes:您现在可以使用属性设置图标:

<p-fileUpload chooseIcon="pi pi-upload" uploadIcon="pi pi-arrow-up" cancelIcon="pi pi-stop></p-fileUpload>

No longer any need for css overrides for this.不再需要 css 覆盖。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM