溫馨提示×

您好,登錄后才能下訂單哦!

密碼登錄×
登錄注冊(cè)×
其他方式登錄
點(diǎn)擊 登錄注冊(cè) 即表示同意《億速云用戶服務(wù)條款》

React BootStrap用戶體驗(yàn)框架快速上手

發(fā)布時(shí)間:2020-09-23 04:26:29 來源:腳本之家 閱讀:182 作者:學(xué)習(xí)筆記666 欄目:web開發(fā)

官方文檔http://react-bootstrap.github.io/getting-started.html

安裝

在終端cd到你的項(xiàng)目目錄下執(zhí)行:$ npm install react-bootstrap

然后需要我們手動(dòng)引用css

<!-- Latest compiled and minified CSS -->
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/latest/css/bootstrap.min.css">
<!-- Optional theme -->
<link rel="stylesheet" >

但是我們?cè)趯W(xué)習(xí)的時(shí)候使用外部的URL,太慢了。因此我們索引把bootstrap安裝到本地。

$ npm install bootstrap

然后你會(huì)發(fā)現(xiàn)在你的node_modules目錄下多了bootstrap。

這樣頁(yè)面上就可以引用本地的css了

<link rel="stylesheet" type="text/css" href="node_modules/bootstrap/dist/css/bootstrap.min.css" rel="external nofollow" rel="external nofollow" >

好,我們動(dòng)手來使用一下React-BootStrap框架吧

http://react-bootstrap.github.io/components.html

我們這里演示使用它的導(dǎo)航條組件

在index.js里:

const React = require("react");
const ReactDOM = require("react-dom");
import {Navbar} from "react-bootstrap";
const navbarInstance = (
  <Navbar>
    <Navbar.Header>
      <Navbar.Brand>
        <a href="#" rel="external nofollow" >react-bootstrap</a>
      </Navbar.Brand>
    </Navbar.Header>
  </Navbar>
);
// 然后我們渲染到body里
ReactDOM.render(navbarInstance,document.body);

html頁(yè)面上:

<!DOCTYPE html>
<html>
<head>
  <title>es2105的寫法</title>
  <meta charset="utf-8">
  <link rel="stylesheet" type="text/css" href="node_modules/bootstrap/dist/css/bootstrap.min.css" rel="external nofollow" rel="external nofollow" >
</head>
<body>
<div id="abc"></div>
</body>
  <script src="webpack-dev-server.js"></script>
  <script src="index-webpack.js"></script>
</html>

效果如下:

React BootStrap用戶體驗(yàn)框架快速上手 

主要看瀏覽器地址,這是我們前面配置的”熱啟動(dòng)”。

執(zhí)行命令 $ npm start 就開啟了服務(wù)

總結(jié)

以上所述是小編給大家介紹的React BootStrap用戶體驗(yàn)框架快速上手,希望對(duì)大家有所幫助,如果大家有任何疑問請(qǐng)給我留言,小編會(huì)及時(shí)回復(fù)大家的。在此也非常感謝大家對(duì)億速云網(wǎng)站的支持!

向AI問一下細(xì)節(jié)

免責(zé)聲明:本站發(fā)布的內(nèi)容(圖片、視頻和文字)以原創(chuàng)、轉(zhuǎn)載和分享為主,文章觀點(diǎn)不代表本網(wǎng)站立場(chǎng),如果涉及侵權(quán)請(qǐng)聯(lián)系站長(zhǎng)郵箱:is@yisu.com進(jìn)行舉報(bào),并提供相關(guān)證據(jù),一經(jīng)查實(shí),將立刻刪除涉嫌侵權(quán)內(nèi)容。

AI