在rails标签中,带连字符的属性的语法是什么?例如,data-something: "1234"
是无效的语法。
<%= link_to "foo", "/bar", class: "myClass", id: "myID", data-something: "1234" %>
答案 0 :(得分:2)
已经有答案,但一般来说使用“带连字符的属性”(不确定这是否是科学术语),只是将它包装成这样......
<%= link_to "foo", "/bar", "data-something" => "1234" %>
答案 1 :(得分:1)
尝试:
<%= link_to "foo", "/bar", class: "myClass", id: "myID", data: { something: "1234"} %>