Home > Software engineering >  importing bootstrap in vuejs
importing bootstrap in vuejs

Time:11-23

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 > -- this is the bootstrap components
  <div >
    <form >
      <input  type="search" placeholder="Search" aria-label="Search">
      <button  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>

CodePudding user response:

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

  • Related