0

Im new to Vuejs and I get the error unknown custom element -

how do i register a custom element - b-alert. I think this element is from bootstrapVue.

<template>
<div>
 <b-alert show>Default Alert</b-alert>



  </div> 
   </template>

    <script>
   export default {
    data () {
            return {
                 dismissSecs: 10,
                 dismissCountDown: 0,
                 showDismissibleAlert: false
            }
    },
                  methods: {
             countDownChanged (dismissCountDown) {
                     this.dismissCountDown = dismissCountDown
             },
             showAlert () {
                     this.dismissCountDown = this.dismissSecs
             }

     },

}

1 Answer 1

6

You will have to register the component as in Component registration

import { Alert } from 'bootstrap-vue/es/components';

components: { BAlert }

Since all html tags are turned into dashed by camelcase BAlert = '<b-alert>'

Alertenativly you can also use

components: { 'b-alert': BAlert }
Sign up to request clarification or add additional context in comments.

3 Comments

I added components: { 'b-alert': BAlert } to the file, now i get an error BAlert is not defined
did you use vue-cli to setup your project, and did you use npm install bootstrap-vue?
BAlert is not defined because you imported Alert not BAlert.

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.