React-Bootstrap是什么?


本文摘自PHP中文网,作者青灯夜游,侵删。

React-Bootstrap是一款基于ReactJS对Bootstrap进行封装的库,一个可重用的前端组件库,可通过“cnpm install react-bootstrap --save”命令进行安装。

React-Bootstrap是什么

React-Bootstrap是一款基于ReactJS对Bootstrap进行封装的库,是一个是可重用的前端组件库。

react-bootstrap的样式组件依赖于bootstrap。

官网:https://react-bootstrap.github.io

安装React-Bootstrap的方法

使用以下命令进行安装

1

2

3

4

cnpm  install react-bootstrap  --save

 

//或者

$ bower install react react-bootstrap

使用:

写内容组件要用到react-bootstrap的组件的时候,要从react-bootstrap中导入所需的组件;

例如:在组件component.js中,要用到React-bootstrap的Button组件,具体写法如下:

1

2

3

4

5

6

7

8

9

10

11

12

13

14

import React  from‘react’;

import  {Button} from ‘react-bootstrap’;

export  default class  MyComponent  React.Component{

constructor(props){

super(props);

}

render(){

return(

<div>

       <Button bsStyle="default"></Button>

</div>          

);

}

};

在index.ejs的模板头部,引入bootstrap.css。在dist文件夹下放入bootstrap.css源码。

样式表

由于 React-Bootstrap 不依赖于具体的 Bootstrap 版本, 所以发行包中不包括任何 css。尽管使用这些组件时,一些样式表是必须的。 如何选择和加载 bootstrap 样式文件由使用者决定,最简单的办法就是从 CDN 上加载最新的样式表文件。

1

2

3

4

5

<!-- Latest compiled and minified CSS -->

<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/latest/css/bootstrap.min.css">

 

<!-- Optional theme -->

<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/latest/css/bootstrap-theme.min.css">

更多编程相关知识,请访问:编程学习网站!!

以上就是React-Bootstrap是什么?的详细内容,更多文章请关注木庄网络博客

相关阅读 >>

一些关于react的常见面试题(分享)

当 position:sticky 遇到 bootstrap 浮动布局时候的踩坑记录

bootstrap原理是什么

bootstrap的优点和缺点是什么?

用react怎么实现收藏功能

如何利用bootstrap分页

react redux是什么?

bootstrap基本结构有哪些

bootstrap怎么实现响应式

什么情况下用bootstrap栅格系统

更多相关阅读请进入《React-Bootstrap》频道 >>




打赏

取消

感谢您的支持,我会继续努力的!

扫码支持
扫码打赏,您说多少就多少

打开支付宝扫一扫,即可进行扫码打赏哦

分享从这里开始,精彩与您同在

评论

管理员已关闭评论功能...