我正在使用这个 code在 AngularJS 站点上显示 toast 。我需要知道如何将换行符 ( <br/>
) 放入正文中。当我使用此 question 中显示的选项时, toastr 在屏幕上呈现标签,而不是将其解释为 HTML。我怎样才能在 toast 中换行?
最佳答案
有两种方法可以在 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'
});
关于javascript - 在 AngularJS 中将换行符(换行符)放入 toastr 消息中?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31254459/