ruby-on-rails – 如何将aria-label属性添加到视图中的链接?
发布时间:2020-12-17 04:02:01 所属栏目:百科 来源:网络整理
导读:我正在尝试将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.projec
我正在尝试将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'),'aria-label' => get_aria_label_current_page('home') %> 更新 在ruby 2.2中你现在可以这样做: 'aria-label': get_aria_label_current_page('home') (编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |