How to include bootstrap css and js in reactjs app?

后端 未结 19 1155
既然无缘
既然无缘 2020-12-04 05:07

I am newb to reactjs, I want to include bootstrap in my react app

I have installed bootstrap by npm install bootstrap --save

Now, want to load b

19条回答
  •  死守一世寂寞
    2020-12-04 05:35

    Via npm, you would run the folowing

    npm install bootstrap jquery --save
    npm install css-loader style-loader --save-dev
    

    If bootstrap 4, also add dependency popper.js

    npm install popper.js --save
    

    Add the following (as a new object) to your webpack config

    loaders: [
        {
          test: /\.css$/,
          loader: 'style-loader!css-loader'
        }
    

    Add the following to your index, or layout

    import 'bootstrap/dist/css/bootstrap.css';
    import 'bootstrap/dist/js/bootstrap.js';
    

提交回复
热议问题