Search code examples
vue.jsvuejs2cdn

Using Vue.js / Bootstrap-vue.js CDN and components


forgive my ignorance here, I am super new to Vue. I am looking for a way to utilize bootstrap-Vue from CDN (https://bootstrap-vue.js.org/docs/ click browser on right nav). I am not seeing how to call the components. Using the webpack / CLI version, no problems, but CDN, I am lost at how to use this.

I put up a simple codepen.io to test this. I've added the CSS and js files per the docs.

https://codepen.io/jasonflaherty/pen/rrzbxj

//do I need this?
Vue.use(BootstrapVue);

//try individual components.
import { Card } from 'bootstrap-vue/es/components';
Vue.use(Card);

What am I missing to utilize bootstrap-vue.js CDN? Do I need to import differently?


Solution

  • Just include the required CDN below and without invoking Vue.use(XXX) (There is a Basic example from the official website.)

            <!-- Required Stylesheets -->
            <link
              type="text/css"
              rel="stylesheet"
              href="https://unpkg.com/bootstrap/dist/css/bootstrap.min.css"
            />
            <link
              type="text/css"
              rel="stylesheet"
              href="https://unpkg.com/bootstrap-vue@latest/dist/bootstrap-vue.css"
            />
    
            <!-- Required scripts -->
            <script src="https://unpkg.com/vue"></script>
            <script src="https://unpkg.com/bootstrap-vue@latest/dist/bootstrap-vue.js"></script>
    


    When you run the Basic example, you will get the bootstrap decoration. enter image description here