2017-05-05 66 views
1
var text += '<b>Hii This is Error<b>'; 
swal("Required", text, "error"); 

如何在Bootstrap Sweet alert插件中使用html编码。如何在甜蜜警报中使用html标记

在上面的代码我必须写为一个错误消息!在sweetalert中显示。但在文本变量中使用html标记时,它需要字符串 ,并且可以在sweetalert中显示相同的字符串,它不能在html标记中进行转换。

回答

0

您必须添加html:true用于显示例如HTML内容,

swal({ 
    title: "Required", 
    text: "<b>Hii This is Error<b>", 
    html: true, // add this if you want to show HTML 
    type: "error" // type can be error/warning/success 
}); 

Sweetalert configuration

+0

谢谢你......为解决 –

+0

如果作品!然后,将其标记为答案,以便它可以帮助其他SO用户。 –

0
swal({ 
title: "Required", 
text: "<b>Please fill the required fields</b>", 
html: true, 
type: "error" 
}); 
相关问题