4

我想添加 fontawesome 图标

<i class="fa fa-trash-o"></i> 

代替“毁灭”

<%= link_to 'Destroy', post_path(post), method: :delete, data: { confirm: 'Are you sure?' } %> 
4

2 回答 2

14

你可以试试

<%= link_to(
      content_tag(
        :i,
        nil, 
        class: 'fa fa-trash-o'
      ), 
      method: :delete, 
      data: { 
        confirm: 'Are you sure?' 
      } 
    ) 
%>

你可以尝试其他不:i喜欢的东西,:div如果你想要里面的文本,<i>TEXT</i>你可以尝试使用 TEXT 而不是 nil,希望这对你有所帮助。

于 2013-11-15T02:01:54.287 回答
3

你也可以像这样使用一个块

<%= link_to post_path(post), method: :delete, data: { confirm: 'Are you sure?' } do %>
    <i class="fa fa-trash-o"></i> 
<% end %>
于 2018-05-31T09:46:35.510 回答