b-nav-item: Option for plain link when using vue-router
See original GitHub issueHow do I use the navbar component’s <b-nav-item>
to generate a non-router-link component? Before I was able to use the href
attr instead of the to
attr to get plain links vs. router-links (respectively).
My project mixes router-controlled links with real links regularly, so this is a must for me. I’m pretty sure some of the last changes switched this up on me. I’ve been looking for a vue-router solution, but everyone just says use a normal <a>
tag. I’m trying to avoid rewriting all the bootstrap markup that this lib does for me so well though!
Here’s the gist of the navbar:
<template>
<b-navbar toggleable fixed="top" type="inverse" variant="inverse">
<b-nav-toggle target="hd-navbar-content"></b-nav-toggle>
<b-link class="navbar-brand">
<a href="https://artisanhd.com">
<img src="/hd-assets/images/artisanhd-logo-light.svg" alt="ArtisanHD" height="40">
</a>
</b-link>
<b-collapse is-nav id="hd-navbar-content">
<b-nav is-nav-bar>
<b-nav-item to="/customer/">My Account</b-nav-item>
<!-- These links need to defer to the browser navigator -->
<!-- ignore the url prefixing... it's for a reverse proxy, not a vue-router thing -->
<b-nav-item :href="'/uploadconfigure/' | applyUrlPrefix">Start Order</b-nav-item>
<b-nav-item :href="'/customer/login' | applyUrlPrefix">
<span v-if="isLoggedIn">Logout</span>
<span v-else>Login</span>
</b-nav-item>
</b-nav>
</b-collapse>
</b-navbar>
</template>
Issue Analytics
- State:
- Created 6 years ago
- Reactions:1
- Comments:17 (12 by maintainers)
Top Results From Across the Web
Nav | Components - BootstrapVue
<b-nav-item> for actionable links (or router-links) ... Use the <b-nav-text> child component to place plain text content into the nav: Link 1; Link...
Read more >When the name of a router link is dynamic how should we ...
Each item should have a link related to its name. Because I don't want to hard code the links I don't know how...
Read more >How to Use a Button as a Link in Vue.js
Use Vuetify button as the Vue Router link. When using Vue Router with Vuetify, we can use the button component as a router...
Read more >The `router-link` Component in Vue - Mastering JS
The `router-link` component is the preferred way to create links with Vue router. ... Note that <router-link> becomes a plain-old <a> tag.
Read more >Navbar | Components | BootstrapVue
Control the text color by setting type prop to light for use with light background color variants, ... <b-nav-item> for link (and router-link)...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
A working example:
https://github.com/vandorjw/assessment-web/blob/master/src/components/blocks/HeaderBlock/Header.vue#L11
demo: https://vandorjw.github.io/assessment-web/#/
<b-nav-item :to="{ name: 'SurveyList'}">Survey List</b-nav-item>
It didn’t work for me without the
:
colon in front ofto
Correct:
:to=
Incorrectto=
@abinhho
<b-nav-item>
supports thehref
prop which renders a plain link, theto
prop will render a router-link