admin管理员组文章数量:1312709
How can I add custom property (aria-selected) to link, if route is active? All docs talk about customizing class.
Something along those lines:
<!-- draw tabs -->
<ul>
<li>
<router-link
:to="{ name: 'tab1' }"
:aria-selected="isActive" <-- ???
>
Tab1
</router-link>
<router-link
:to="{ name: 'tab2' }"
:aria-selected="isActive" <-- ???
>
Tab2
</router-link>
...
How can I add custom property (aria-selected) to link, if route is active? All docs talk about customizing class.
Something along those lines:
<!-- draw tabs -->
<ul>
<li>
<router-link
:to="{ name: 'tab1' }"
:aria-selected="isActive" <-- ???
>
Tab1
</router-link>
<router-link
:to="{ name: 'tab2' }"
:aria-selected="isActive" <-- ???
>
Tab2
</router-link>
...
Share
Improve this question
edited Feb 1 at 13:57
JohnSmith
asked Jan 31 at 16:00
JohnSmithJohnSmith
4721 gold badge5 silver badges21 bronze badges
1 Answer
Reset to default -1I need to check current route name:
<router-link
:to="{ name: 'tab1' }"
:aria-selected="$route.name === 'tab1'"
>
Tab1
</router-link>
本文标签: vuejs3How to add custom property to Vue3 routerlink if route is activeStack Overflow
版权声明:本文标题:vuejs3 - How to add custom property to Vue3 router-link if route is active? - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1741908274a2404279.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论