i'm using vue cli . I have installed bootstrap using npm install bootstrap command. i have successfully imported @import "../node_modules/bootstrap/dist/css/bootstrap.min.css" ; on vue component but when i include script <script src="../node_modules/bootstrap/dist/js/bootstrap.min.js"></script> on index.html before closing body tag its not working.
3 Answers
Import the bootstrap js file just in main.js just like you did with the css file. So add import 'bootstrap' to the main.js.
5 Comments
npm install bootstrap . but do not know how to add bootstrap.min.jsInstall bootstrap using npm
npm install bootstrap
Edit src/main.js file of your app. Import like this.
import 'bootstrap/dist/css/bootstrap.min.css'
import 'bootstrap/dist/js/bootstrap.min.js'
Comments
This also happened to me. I did a lot of searching, but no one had the right answer.
I used Bootstrap v5.3.3 and Vue3. I had no idea why it works :D.
Just Remove any bootstrap/boostrap.bundle.min.js import either in main.js or index.html.
All you need is to import the bootsrap.min.css ONLY on your main.js and boom it's working properly, including the dropdown, accordion, etc.
I even remove popperjs its still working fine.