甜蜜警示显示文本中的HTML代码 [英] sweet-alert display HTML code in text
问题描述
我正在使用sweet-alert插件来显示警报。使用经典配置(默认值),一切正常。但是,当我想在TEXT中添加HTML标记时,它会显示< b> ...< / b>
而不会使其变为粗体。在搜索答案后,看起来我没有正确的搜索词...
I am using sweet-alert plugin to display an alert. With a classical config (defaults), everything goes OK. But when I want to add a HTML tag into the TEXT, it display <b>...</b>
without making it bold. After searching for the answer, it looks like I don't have the right search word...
如何使用HTML代码制作甜蜜的警告显示文本?
How to make sweet alert display the text also with HTML code?
var hh = "<b>test</b>";
swal({
title: "" + txt + "",
text: "Testno sporocilo za objekt " + hh + "",
confirmButtonText: "V redu",
allowOutsideClick: "true"
});
推荐答案
SweetAlert仓库似乎没有维护。有一堆Pull Requests没有任何回复,最后一次合并拉取请求是在2014年11月9日。
The SweetAlert repo seems to be unmaintained. There's a bunch of Pull Requests without any replies, the last merged pull request was on Nov 9, 2014.
我创建了 SweetAlert2 ,在模态中支持HTML,其他一些选项用于自定义模态窗口 - 宽度,填充,Esc按钮行为等。
I created SweetAlert2 with HTML support in modal and some other options for customization modal window - width, padding, Esc button behavior, etc.
Swal.fire({
title: "<i>Title</i>",
html: "Testno sporocilo za objekt: <b>test</b>",
confirmButtonText: "V <u>redu</u>",
});
<script src="https://cdn.jsdelivr.net/npm/sweetalert2@8"></script>
这篇关于甜蜜警示显示文本中的HTML代码的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!