如何调整toastr消息在Angular中的宽度

如何调整toastr消息在Angular中的宽度,angular,angular9,toastr,angular-toastr,ngx-toastr,Angular,Angular9,Toastr,Angular Toastr,Ngx Toastr,我有来自npm的使用ngx toastr的toastr消息通知(我当前的堆栈是Angular 9) 有没有办法改变消息的最大宽度,因为它会导致消息文本换行 this.toastrService.error( 'This is an error message to be displayed<br> please log back','', { enableHtml: true } ). this.toastrService.e

我有来自npm的使用ngx toastr的toastr消息通知(我当前的堆栈是Angular 9)

有没有办法改变消息的最大宽度,因为它会导致消息文本换行

this.toastrService.error(
          'This is an error message to be displayed<br> please log back','',
          { enableHtml: true }
        ).
this.toastrService.error(
“这是要显示的错误消息,
请重新登录,”, {enableHtml:true} ).


我希望显示的也位于第一行

您可以使用本机类,即
烤面包顶部全宽
烤面包底部全宽

 <toaster-container toaster-options="{
   'time-out': 2500, 
   'close-button':false, 
   'position-class':'toast-bottom-full-width'
  }"></toaster-container>
CSS:

在评论澄清后更新

从文档中:

设置单个选项

成功
错误
信息
警告
获取(消息、标题、ToastConfig)传递选项对象以替换任何默认选项

例如:

this.toastrService.error('everything is broken', 'Major Error', {
  timeOut: 3000,
});
例如,在您的案例中,这将是:

this.toastrService.error(
          'This is an error message to be displayed<br> please log back','',
          { enableHtml: true,
            position-class:'toast-bottom-full-width' 
          }
        ).
this.toastrService.error(
“这是要显示的错误消息,
请重新登录,”, {enableHtml:true, 职位类别:'toast-bottom-full-width' } ).
或者使用您自己的自定义类:

this.toastrService.error(
          'This is an error message to be displayed<br> please log back','',
          { enableHtml: true,
            position-class:'my-own-toastr-class' 
          }
        ).
this.toastrService.error(
“这是要显示的错误消息,
请重新登录,”, {enableHtml:true, 职位类别:'my-own-toastr-class' } ).

请查看选项下的更多信息。

我的应用程序中没有任何位置。我已从npm下载了ngx toastr,我只是使用带有内置显示方法的typescript代码notifications@VigneshRavichandran也许你想在你的问题中包括这个事实和你调用toastr的实际代码,这样人们就不会有这样的问题了猜。。无论如何,您仍然可以通过.ts文件中的toaster选项实例化toaster。我已经更新了这个问题,以获得更好的效果understanding@VigneshRavichandran我更新了我的答案。我认为position类必须添加到根模块
this.toastrService.error(
          'This is an error message to be displayed<br> please log back','',
          { enableHtml: true,
            position-class:'toast-bottom-full-width' 
          }
        ).
this.toastrService.error(
          'This is an error message to be displayed<br> please log back','',
          { enableHtml: true,
            position-class:'my-own-toastr-class' 
          }
        ).