Sweetalert: 支持消息中的新行吗?

创建于 2015-06-03  ·  9评论  ·  资料来源: t4t5/sweetalert

请问标题是什么??

最有用的评论

如果您将html属性设置为实际的 html 本身(即去掉text属性并将html属性设置为 html 内容),它就会起作用,例如

$swal({
  title: "My title",
  type: "error",
  html: "My text with<br />html included"
});

所有9条评论

如果将html属性设置为true ,则可以使用换行符 --> <br/>标记。

我怎么做?

swal({ html: true, title: 'hi', text: 'te<br>st' });
似乎对我不起作用

ps 我使用 pr https://github.com/t4t5/sweetalert/pull/772来简化使用,现在一切正常

我应该如何将 html 属性设置为 true? html 属性的顺序是什么,为什么没有记录? 谢谢你。

如果您将html属性设置为实际的 html 本身(即去掉text属性并将html属性设置为 html 内容),它就会起作用,例如

$swal({
  title: "My title",
  type: "error",
  html: "My text with<br />html included"
});

它对我有用,请使用 \n
swal("糟糕", "第 1 行。 \n 第2 行。", "错误");

它只适用于这样的文本的一部分:
swal("Oops", "Line 1.\n line2.", "error");
但如果你想把它作为标题的一部分......它不起作用:
swal("Oops\nOops", "Line 1", "error");

抱歉,但在我看来,在标题中使用多行(并遵循良好的设计规范)是没有意义的。

编辑:感谢@themightystephen

swal({ buttons: ["Wait ", "Add Details"], html: true, text: "Text one .\n Text 2.\n Text 3." })
这是解决方案。 在反应中完美运行。 享受

此页面是否有帮助?
0 / 5 - 0 等级

相关问题

fracz picture fracz  ·  4评论

sastrahost picture sastrahost  ·  5评论

blackrosezy picture blackrosezy  ·  6评论

mouro001 picture mouro001  ·  3评论

Untit1ed picture Untit1ed  ·  5评论