Adding bootstrap to Vue CLI project

后端 未结 7 1177
轻奢々
轻奢々 2021-01-31 09:58

I\'m new to Vue and webpack in general and I\'m having a hard time figuring out how to import things.

I created a fresh Vue project through vue init I added

7条回答
  •  慢半拍i
    慢半拍i (楼主)
    2021-01-31 10:07

    For Gridsome users, the solution is exactly the same!

    yarn add jquery bootstrap popper.js
    
    import 'jquery/src/jquery.js';
    import 'popper.js/dist/popper.min.js';
    import 'bootstrap/dist/js/bootstrap.min.js';
    

    You can also import the css here like this import 'bootstrap/dist/css/bootstrap.min.css' however bootstrap provides a SCSS file which can be highly customisable, if you want this kind of customisation, import in the main.js file a new scss file

    // Load core styling
    import '~/assets/styles/core.scss';
    

    and then import bootstrap like this

    @import '~bootstrap/scss/bootstrap';
    @import 'theme.scss';
    

    The theme.scss follows this document https://getbootstrap.com/docs/4.0/getting-started/theming/

提交回复
热议问题