create-react-app搭建的项目中添加bootstrap

react-bootstrap是一个很是受欢迎的针对react封装过的bootstrap,它自己不包含css,因此也是须要使用bootstrap原生库。css

在create-react-app建的项目目录中安装react-bootstrap。html

npm install react-bootstrap --save

安装bootstrap。react

npm install bootstrap@3.3.7 --save

 

在index.js文件中增长css引用。git

import 'bootstrap/dist/css/bootstrap.css';
import 'bootstrap/dist/css/bootstrap-theme.css';

 

在须要用到bootstrap组件的代码中,引入所需组件。github

import { Navbar, Jumbotron, Button } from 'react-bootstrap';

 

react-bootstrap参考:npm

https://github.com/facebookincubator/create-react-app/blob/master/packages/react-scripts/template/README.md#adding-bootstrapbootstrap

https://react-bootstrap.github.io/getting-started.htmlapp

 

Endspa

相关文章
相关标签/搜索