【发布时间】:2015-09-24 02:35:49
【问题描述】:
我正在使用这个code 在 AngularJS 网站上显示祝酒词。我需要知道如何在正文中添加换行符 (<br/>)。当我使用question 中显示的选项时,toastr 会在屏幕上呈现标签,而不是将其解释为 HTML。如何在 toast 中换行?
【问题讨论】:
标签: javascript angularjs toastr
我正在使用这个code 在 AngularJS 网站上显示祝酒词。我需要知道如何在正文中添加换行符 (<br/>)。当我使用question 中显示的选项时,toastr 会在屏幕上呈现标签,而不是将其解释为 HTML。如何在 toast 中换行?
【问题讨论】:
标签: javascript angularjs toastr
有两种方法可以在 toast 中允许一些 HTML 标记,包括换行符。
在toaster-options 中包含'body-output-type': 'trustedHtml':
<toaster-container toaster-options="{
'closeButton': false,
'debug': false,
'position-class': 'toast-bottom-right',
'onclick': null,
'showDuration': '200',
'hideDuration': '1000',
'timeOut': '5000',
'extendedTimeOut': '1000',
'showEasing': 'swing',
'hideEasing': 'linear',
'showMethod': 'fadeIn',
'hideMethod': 'fadeOut',
'body-output-type': 'trustedHtml'
}"></toaster-container>
或者在对toaster.pop()的调用中包含'trustedHtml':
toaster.pop('success', 'Saved', 'Saved<br/>it!', 3000, 'trustedHtml');
或
toaster.pop({
type: 'success',
title: 'Saved',
body: 'Saved<br/>it!',
bodyOutputType: 'trustedHtml'
});
【讨论】: