如何在toastr中显示多行错误消息?
我已经按以下方式格式化我的错误消息
"Please fix the following: \r\nFirst Name is required\r\nLast Name is required\r\nEmail Address is required\r\n"
但是在 toast 中,它显示为单行。请帮忙。
如何在toastr中显示多行错误消息?
我已经按以下方式格式化我的错误消息
"Please fix the following: \r\nFirst Name is required\r\nLast Name is required\r\nEmail Address is required\r\n"
但是在 toast 中,它显示为单行。请帮忙。
根据Dr. Stitch所说,toastr使用字符串作为html,因此我们必须为新行添加<br>:
Please fix the following: </br>First Name is required</br>Last Name is required</br>Email Address is required</br>
- 更新:2020年12月15日:
对于版本12+:
toastr.success('Please fix the following: </br>First Name is required</br>Last Name is required</br>Email Address is required</br>', '', { closeButton: true, timeOut: 4000, progressBar: true, allowHtml: true });
这会起作用!!!感谢您的帮助。
允许HTML格式: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 });
enableHtml
而不是allowHtml
,<br />
作为HTML标签。旧版本也可能已经更改了此设置。this.toastr.success('First Name is required<br />Last Name is required<br />Email Address is required<br />', {
enableHtml: true
});
use '\n' in your string and add this style