2016-04-25 49 views
2

我一直在努力boostrap反應3小時。我試圖找到問題和我的問題的答案。 Bootstrap React的bsStyle完全不起作用,所以我想知道它爲什麼?我見過這麼多的例子,他們只是像我所做的那樣導入。bsStyle的Bootstrap反應不起作用

import {Button} from 'react-bootstrap'; 

,但我仍然得到簡單的按鈕,沒有任何風格 這裏我的組件

export class bsButton extends React.Component{ 
render() { 
     return (
      <div> 
       <Button bsStyle="primary">primary button</Button> 
      </div> 
     ); 
    } 
} 

什麼是錯我的進口或我的組件的代碼? 您的幫助表示讚賞:D

+1

您有加入樣式表? https://react-bootstrap.github.io/getting-started.html – Will

+0

天啊!我沒有讀過它,我從來沒有想過我需要導入原始引導程序的CSS文件,因爲我從npm安裝它。我的材料也安裝在我的項目上。材料的UI沒有CSS,所以我只是導入它的類名,然後它會給我一個很好的風格...但是,boostrap反應...無論如何感謝您的想法 –

+0

我已經添加了一個答案,如果你將它標記爲正確的:) – Will

回答

2

您需要確保您已將引導程序CSS添加到頁面頭部。 Getting Started這可以通過NPM添加庫時容易忘記

+0

是的!我曾經從atmospherejs.com安裝流星包,而且我不必包括頭部或任何東西。我認爲npm包與我所知道的類似,但是...不同:D我使用流星+反應來創建web應用程序。我的工作會受到很多挫折。感謝您的想法:D –

0

在公衆包括

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

/index.html的

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

來源:here