Search code examples
vue.jsbootstrap-vue

importing bootstrap in vuejs


I am trying to build the web using VueJs with Bootstrap but whenever I add the Bootstrap imports, the website goes blank. Even when I add the bootstrap components, it is blank too. Could anyone guide me please?

Here is my imports on main.js

import { createApp } from 'vue'
import App from './App.vue'
import BootstrapVue from 'bootstrap-vue'
import 'bootstrap/dist/css/bootstrap.css'
import 'bootstrap-vue/dist/bootstrap-vue.css'

App.use(BootstrapVue)
createApp(App).mount('#app')

My App.vue

<template>
  <img alt="Vue logo" src="./assets/logo.png">
  <HelloWorld msg="Welcome to Your Vue.js App"/>

  <nav class="navbar navbar-light bg-light"> -- this is the bootstrap components
  <div class="container-fluid">
    <form class="d-flex">
      <input class="form-control me-2" type="search" placeholder="Search" aria-label="Search">
      <button class="btn btn-outline-success" type="submit">Search</button>
    </form>
  </div>
</nav> --- bootstrap components

</template>

<script>
import HelloWorld from './components/HelloWorld.vue'

export default {
  name: 'App',
  components: {
    HelloWorld
  }
}
</script>

<style>
#app {
  font-family: Avenir, Helvetica, Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-align: center;
  color: #2c3e50;
  margin-top: 60px;
}
</style>

Solution

  • OP achieved a working setup by using Vue2 as somewhat suggested here: importing bootstrap in vuejs