簡體   English   中英

ngx-toastr ToastrService.show() 類型參數 Angular 2 +

[英]ngx-toastr ToastrService.show() type parameter Angular 2 +

我可以ToastrService.success/error/warning/info()使用ToastrService.success/error/warning/info()

但是當我使用ToastrService.show()我不知道應該發送哪種正確的字符串類型

我嘗試發送這樣的枚舉:

 export enum ToastType { Success = 'success', Error = 'error', Info = 'info', Warning = 'warning' }

但是組件丟失了樣式。

偶然發現了同樣的問題,並在文檔中找到了類型:

iconClasses = {
  error: 'toast-error',
  info: 'toast-info',
  success: 'toast-success',
  warning: 'toast-warning'
};

來源: https : //github.com/scttcper/ngx-toastr#iconclasses-defaults

更新

show() 方法接受四個參數,其中類型是上面列出的名稱。

ToastrService.show(message?: string, title?: string, override?: Partial<IndividualConfig>, type?: string)

可以在此處查看包含所有參數的示例: https : //stackblitz.com/edit/angular-uu7r6s

或者更完整的例子: https : //github.com/grabowskidaniel/exemplo-ngx-toastr

使用 NgxToastr 版本 10

我像這樣使用 ToasterService,

this._toasterService.openToast("", "update success!", "success");

this._toasterService.openToast("", "update error!", "error");

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM