4

I am working on a Vue application. I use bootstrap-vue navbar from this official example in my application. But, when I run my project, in the console, Vue keeps warning me about the unknown custom element <b-nav-brand> which I have included in my main.js.

Here is my set up if you have any ideas.

Error:

[Vue warn]: Unknown custom element: - did you register
the component correctly? For recursive components, make sure to provide the "name" option.

Navbar Code:

<b-navbar class="nav-bar" toggleable="sm">
    <b-navbar-toggle target="nav_collapse"></b-navbar-toggle>
    <b-nav-brand class="logo" href="#">
      <img src="/static/images/boost-icon.svg" alt="Boost icon"/>
      <h1>Portal</h1>
    </b-nav-brand>
    <b-collapse is-nav id="nav_collapse">
      <b-navbar-nav class="ml-auto">
        <b-nav-item href="">
          <span class="btn btn-primary btn-request-access">Request Access</span>
        </b-nav-item>
      </b-navbar-nav>
    </b-collapse>
  </b-navbar>

Main.JS:

Vue.use(BootstrapVue)
new Vue({
  el: '#app',
  router: router,
  template: '<App/>',
  store: store,
  components: {
    App
  }
})
0

3 Answers 3

6

Because its <b-navbar-brand> in the docs.

<link type="text/css" rel="stylesheet" href="//unpkg.com/bootstrap/dist/css/bootstrap.min.css"/>
<link type="text/css" rel="stylesheet" href="//unpkg.com/bootstrap-vue@latest/dist/bootstrap-vue.css"/>

<script src="//unpkg.com/babel-polyfill@latest/dist/polyfill.min.js"></script>
<script src="//unpkg.com/bootstrap-vue@latest/dist/bootstrap-vue.js"></script>

<div>
  <!-- Image and text -->
  <b-navbar variant="faded" type="light">
    <b-navbar-brand href="#">
      <img src="https://placekitten.com/g/30/30" class="d-inline-block align-top" alt="BV">
      BootstrapVue
    </b-navbar-brand>
  </b-navbar>
</div>

Sign up to request clarification or add additional context in comments.

1 Comment

Really thanks for pointing out. Haha. Need to be careful next time.
0

You can also import it

import { BNavbar } from 'bootstrap-vue'
Vue.component('b-navbar', BNavbar)

or

import { NavbarPlugin } from 'bootstrap-vue'
Vue.use(NavbarPlugin)

On the bootstrap-vue docs they like to tell you how you can get started, import, at the bottom of the page.

Comments

0

Just import whatever you want to use.

Here is a sample code.

<script>
import {
   BNavbarToggle, BNavItem, BNavbarBrand, BNavbar, BNavbarNav, BNavItemDropdown, BDropdownItem, BDropdownDivider, BAvatar,  BCollapse, BNav, BContainer, BRow, BCol, BLink, BFormGroup, BFormInput, BInputGroupAppend, BInputGroup, BFormCheckbox, BCardText, BCardTitle, BImg, BForm, BButton,
} from 'bootstrap-vue'

export default {
  components: {
    BNavbarToggle,
    BNavItem,
    BNavbarBrand,
    BNavbarNav,
    BNavItemDropdown,
    BDropdownItem,
    BDropdownDivider,
    BAvatar,
    BCollapse,
    BNavbar,
    BNav,
    BContainer,
    BRow,
    BCol,
    BLink,
    BFormGroup,
    BFormInput,
    BInputGroupAppend,
    BInputGroup,
    BFormCheckbox,
    BCardText,
    BCardTitle,
    BImg,
    BForm,
    BButton,
  },
}
</script>

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.