question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

b-nav-item: Option for plain link when using vue-router

See original GitHub issue

How 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:closed
  • Created 6 years ago
  • Reactions:1
  • Comments:17 (12 by maintainers)

github_iconTop GitHub Comments

5reactions
vandorjwcommented, Sep 15, 2017

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 of to

Correct: :to= Incorrect to=

2reactions
tmorehousecommented, Oct 14, 2019

@abinhho <b-nav-item> supports the href prop which renders a plain link, the to prop will render a router-link

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found