如何在toastr中显示多行消息?

时间:2016-04-28 07:48:59

标签: toastr

如何在toastr中显示多行错误信息?

我已将我的错误信息格式化如下

"Please fix the following: \r\nFirst Name is required\r\nLast Name is required\r\nEmail Address is required\r\n"

但是在toasrt中它显示在单行中。请帮忙

4 个答案:

答案 0 :(得分:8)

正如Dr.Stitch所说,toastr使用字符串作为html,所以我们必须为新行添加:

Please fix the following: </br>First Name is required</br>Last Name is required</br>Email Address is required</br>

这会有效!!!谢谢你的帮助。

答案 1 :(得分:6)

allowHtml:true

toastr.success('\'Second Review\' validation has started. </br>All SME\'s and Reviewers will get an email notification', '', { closeButton: true, timeOut: 4000, progressBar: true, allowHtml: true });

答案 2 :(得分:2)

请注意

ng-toaster v12.1.0

它是enableHtml而非allowHtml,其中<br />为HTML。

在旧版本中也可能会更改。

答案 3 :(得分:-1)

首先导入Toastr服务,然后编写消息并启用HTML

this.toastr.success('First Name is required<br />Last Name is required<br />Email Address is required<br />', { 
enableHtml: true
});
相关问题