如何在2018年用sweetalert制作文字大胆?

时间:2018-02-19 18:51:15

标签: javascript sweetalert

我看到你可以使用内容选项,但我现在还不确定如何解决这个问题,我有类似的内容:

Oid

2 个答案:

答案 0 :(得分:3)

从GitHub问题中,您应该设置内容并在其中插入文本:

var name = "Stack Overflow";
var content = document.createElement('div');
    content.innerHTML = 'Hello <strong>'+ name +'</strong>';

    swal({
        title: 'Hello',
        content: content,
        icon: "success",
    })

答案 1 :(得分:2)

或者,您可以使用SweetAlert2 - 原始SweetAlert支持的分支:

swal({
  title: 'Using HTML tags <u>should be easy<u> ',
  html: 'Overengineering is <strong>a bad thing</strong>'
})
<script src="https://cdn.jsdelivr.net/npm/sweetalert2@7"></script>

PS。请注意,SweetAlert2与SweetAlert略有不同,请查看简单的迁移指南:https://github.com/sweetalert2/sweetalert2/wiki/Migration-from-SweetAlert-to-SweetAlert2