我正在尝试将 aria-label 属性添加到链接以使其更易于访问。当我这样做时,它按预期工作:
<a href="/" class="site-name <%= is_active('home') %>" aria-label="<%= get_aria_label_current_page('home') %>">Version Postman</a>
但这不是:
<%= link_to t('nav.projects'), projects_path, class: is_active('projects'), aria-label: get_aria_label_current_page('home') %>
我收到“意外的 tLABEL”语法错误。任何人都知道这是什么问题?
谢谢。
最佳答案
问题出在标签上的破折号上。试试这个:
<%= link_to t('nav.projects'),
projects_path, class: is_active('projects'),
'aria-label' => get_aria_label_current_page('home') %>
更新
现在在 ruby 2.2 中你可以:
'aria-label': get_aria_label_current_page('home')
关于ruby-on-rails - 如何将 aria-label 属性添加到 View 中的链接?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/26831678/