我使用ruby模板生成链接。这有效:
<% link_to t('features.cta_link')+link_id('features'),
data: { test: t('header.button') } do %>
但我想设置数据属性数据-2,所以我尝试了
<% link_to t('features.cta_link')+link_id('features'),
data: { 2: t('header.button') } do %>
然后我得到了
unexpected ':', expecting => ...ion', itemscope: '', data: { 2: t('header.button') } do ... ^
答案 0 :(得分:2)
我需要使用常规语法:
{ 2 => t('header.button') }