admin管理员组文章数量:1296921
Currently using VueJs and Bootstrap Vue and I'm wondering how to use appending the "active" tag to the Nav links I have set up.
<div>
<b-nav tabs align="center">
<b-nav-item>
<b-link to="/">Home</b-link>
</b-nav-item>
<b-nav-item>
<b-link to="/table">Table</b-link>
</b-nav-item>
</b-nav>
</div>
How would I be able to turn it into the following?
<div>
<b-nav tabs align="center">
<b-nav-item>
<b-link to="/" active>Home</b-link>
</b-nav-item>
<b-nav-item>
<b-link to="/table">Table</b-link>
</b-nav-item>
</b-nav>
</div>
I've tried @click events to toggle a boolean and set a class that way but I've not had much success.
Currently using VueJs and Bootstrap Vue and I'm wondering how to use appending the "active" tag to the Nav links I have set up.
<div>
<b-nav tabs align="center">
<b-nav-item>
<b-link to="/">Home</b-link>
</b-nav-item>
<b-nav-item>
<b-link to="/table">Table</b-link>
</b-nav-item>
</b-nav>
</div>
How would I be able to turn it into the following?
<div>
<b-nav tabs align="center">
<b-nav-item>
<b-link to="/" active>Home</b-link>
</b-nav-item>
<b-nav-item>
<b-link to="/table">Table</b-link>
</b-nav-item>
</b-nav>
</div>
I've tried @click events to toggle a boolean and set a class that way but I've not had much success.
Share asked Jun 7, 2019 at 9:26 Mtlj1991Mtlj1991 1972 gold badges5 silver badges13 bronze badges1 Answer
Reset to default 10You can use the $route object to check the route name and bind it to the active prop.
<b-link to="/table" :active='$route.name =="Table"'>Table</b-link>
本文标签: javascriptToggling active nav items with BootstrapVue and VueJsStack Overflow
版权声明:本文标题:javascript - Toggling active nav items with BootstrapVue and VueJs - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1741646445a2390212.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论