简体   繁体   English

在rails中使用link_to在锚标签上指定其他属性

[英]specifying additional attributes on anchor tag using link_to in rails

Let us say I want an output html like this in rails: 让我们说我想要在rails中这样的输出html:

<a role="menuitem" tabindex="-1" href="#">Action</a></li>

How can I specify the attribues (role and tabIndex) using link_to helper in rails. 如何在Rails中使用link_to帮助器指定属性(角色和tabIndex)。

Check out the Rails docs for link_to 查看Rails文档中的link_to

link_to 'Action', '#', role: 'menuitem', tabindex: -1

should do the trick 应该可以

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM