【问题标题】:how to display multi line message in the toastr ?如何在 toastr 中显示多行消息?
【发布时间】:2016-08-22 20:24:37
【问题描述】:

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

我已将错误消息格式化如下

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

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

【问题讨论】:

标签: toastr


【解决方案1】:

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

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

- 更新:15/12/2020:

对于 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 });

这行得通!!!谢谢你的帮助。

【讨论】:

    【解决方案2】:

    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 });
    

    【讨论】:

      【解决方案3】:

      请注意

      ng-toaster v12.1.0

      它是enableHtml,而不是allowHtml&lt;br /&gt; 是 HTML。

      也可能在旧版本中进行更改。

      【讨论】:

        【解决方案4】:

        首先导入 toastr 服务,然后写入您的消息并启用 HTML

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

        【讨论】:

          猜你喜欢
          • 2016-06-22
          • 2013-02-04
          • 2022-10-07
          • 1970-01-01
          • 1970-01-01
          • 1970-01-01
          • 1970-01-01
          • 1970-01-01
          • 1970-01-01
          相关资源
          最近更新 更多