确认框中的换行符

mar*_*maf 3 newline ruby-on-rails

我想在警报框中有两行

现在我有以下内容:

<%= link_to 'back', 'history.back()', :confirm => 'Are you sure? This is my second line' %>
Run Code Online (Sandbox Code Playgroud)

我尝试添加'\n'但它不起作用,它只是在我的文本之间写入\n.我该怎么办?

先感谢您

小智 11

我认为你的确认文本周围的单引号会导致\n字面上的解释.试试这个:

<%= link_to 'back', 'history.back()', :confirm => "Are you sure? \n This is my second line" %>
Run Code Online (Sandbox Code Playgroud)