简体   繁体   English

ngx-toastr ToastrService.show() 类型参数 Angular 2 +

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

I can use ToastrService.success/error/warning/info() without problem,我可以ToastrService.success/error/warning/info()使用ToastrService.success/error/warning/info()

but when i use ToastrService.show() i don't know which correct string type i should send但是当我使用ToastrService.show()我不知道应该发送哪种正确的字符串类型

i tried send a enum like this:我尝试发送这样的枚举:

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

but the component lose the styles.但是组件丢失了样式。

Stumbled into the same issue and found the types at the docs:偶然发现了同样的问题,并在文档中找到了类型:

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

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

UPDATE更新

The show() method takes four parameters, where the type are the names listed above. show() 方法接受四个参数,其中类型是上面列出的名称。

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

An example with all parameters can be seen here: https://stackblitz.com/edit/angular-uu7r6s可以在此处查看包含所有参数的示例: https : //stackblitz.com/edit/angular-uu7r6s

Or an even more complete example: https://github.com/grabowskidaniel/exemplo-ngx-toastr或者更完整的例子: https : //github.com/grabowskidaniel/exemplo-ngx-toastr

Using NgxToastr version 10使用 NgxToastr 版本 10

I use ToasterService like this,我像这样使用 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