你好
我如何制作多行或使用 html
?
这是我基于https://sweetalert.js.org/docs/#content的 hack
var span = document.createElement("span");
span.innerHTML='abc<br>efg'
swal({
content: span,
});
我相信有更好的方法。
目前, @simon1tan的做法是<br>
标签替换\n
字符,这样人们就可以写:
swal("Hello\nthere!")
如果有人想解决这个问题(应该很简单),请随时发送拉取请求!
一直很难找到使用HTML元素的方法,你的hack帮助了我,非常感谢你的朋友!
PD:“\n”它对我不起作用,它没有换行
我认为自动事情不太好,我认为是更好的不同选择,例如
你可以使用 html 来使用“
”
swal({
标题:'错误',
html: 'Verifique 赞成 e 意图
asdasdasas' ,
显示确认按钮:真,
显示关闭按钮:真,
})
再见
const lines = ['您对我们非常重要,收到的所有信息将始终保密。', '我们将在审核您的消息后立即与您联系。', '我们已通过 '+contact_email+' 向您发送电子邮件, 请检查它以获得快速响应。'];
swal('感谢您联系我们!',lines.join('\n\n'),'success');
//为我工作!
const lines = ['You are very important to us, all information received will always remain confidential.', 'We will contact you as soon as we review your message.', 'We have sent an email to you at '+contact_email+' , Please check it for quick response.'];
swal('Thank you for contacting us!',lines.join('\n\n'),'success');
对于我的情况,添加 div 标签来覆盖文本将起作用
origina: Line0<br />Line1<br /> [not working]
after: <div>Line0<br />Line1<br /></div> [working fine]
swal({
title: 'Mt Title',
html: '<div>Line0<br />Line1<br /></div>',
});
swal({
buttons: ["Wait ", "Add Details"],
html: true,
text: "Text one .\n Text 2.\n Text 3."
})
这是解决方案。 在反应中完美地工作。 享受
最有用的评论
这是我基于https://sweetalert.js.org/docs/#content的 hack
我相信有更好的方法。