How to include bootstrap css and js in reactjs app?

后端 未结 19 1177
既然无缘
既然无缘 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:42

    If you are new to React and using create-react-app cli setup, run the npm command below to include the latest version of bootstrap.

    npm install --save bootstrap
    

    or

    npm install --save bootstrap@latest
    

    Then add the following import statement to index.js file. (https://getbootstrap.com/docs/4.4/getting-started/webpack/#importing-compiled-css)

    import '../node_modules/bootstrap/dist/css/bootstrap.min.css';
    

    or

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

    don't forget to use className as attribute on target elements (react uses className as attribute instead of class).

提交回复
热议问题