与 react-bootstrap 反应。他们如何使用它?

react with react-bootstrap. How they use it?

我刚开始探索 React 并试图了解如何使用 react-bootstrap 如果安装在 bower 上我只是按照入门部分进行操作,但我真的不明白它应该如何工作。

这是我的标记

<!DOCTYPE html>
    <html lang="en">
      <head>
        <meta charset="utf-8">
        <meta http-equiv="X-UA-Compatible" content="IE=edge">
        <meta name="viewport" content="width=device-width, initial-scale=1">
        <!-- The above 3 meta tags *must* come first in the head; any other head content must come *after* these tags -->
        <title>Bootstrap 101 Template</title>

        <!-- Bootstrap -->
        <link href="styles/main.css" rel="stylesheet">
        <script src="vendor/react/react.js"></script>
        <script src="vendor/react-bootstrap/react-bootstrap.js"></script> 
        <script src="vendor/react/JSXTransformer.js"></script>

        <!-- HTML5 shim and Respond.js for IE8 support of HTML5 elements and media queries -->
        <!-- WARNING: Respond.js doesn't work if you view the page via file:// -->
        <!--[if lt IE 9]>
          <script src="https://oss.maxcdn.com/html5shiv/3.7.2/html5shiv.min.js"></script>
          <script src="https://oss.maxcdn.com/respond/1.4.2/respond.min.js"></script>
        <![endif]-->
      </head>
      <body>


         <script>
            var Alert = ReactBootstrap.Alert;
            console.log(Alert)
        </script>

        <!-- jQuery (necessary for Bootstrap's JavaScript plugins) -->
        <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.2/jquery.min.js"></script>
      </body>
    </html>

如何使用这个包生成 bootsrap 组件?

更新

我想我明白了,但我不确定在我的标记中是否正确使用它

 <script>
        var Alert = ReactBootstrap.Alert;
 </script>

 <script src="components/Alert.js"></script>

Alert.js是编译后的jsx

const alertInstance = (
  <Alert bsStyle='warning'>
    <strong>Holy guacamole!</strong> Best check yo self, you're not looking too good.
  </Alert>
);

React.render(alertInstance, document.body);

@dmasi 在评论中提到了它。这看起来像是命名空间问题,并且在 react-bootstrap 网站上提到的示例中缺失。

这里是一个通过 React-Bootstrap 使用 Bootstrap 的 ButtonGroup 的例子。您可以对您的代码采用类似的方法。

<h2>React-Bootstrap Testing</h2>
<div id="myBtn"></div>

<link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.5/css/bootstrap.min.css" rel="stylesheet"/>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.10.0/jquery.min.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.5/js/bootstrap.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/react/0.13.3/react.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/react/0.13.3/JSXTransformer.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/react-bootstrap/0.25.1/react-bootstrap.js"></script>

<script type="text/jsx">
    var MyReactBootstrapButton = React.createClass({
    render: function() {

        var ButtonGroup = ReactBootstrap.ButtonGroup,
            Button  = ReactBootstrap.Button;

        return (<div>
                    <ButtonGroup>
                        <Button>Left</Button>
                        <Button>Middle</Button>
                        <Button>Right</Button>
                    </ButtonGroup>
                </div>);
    }
});

React.render(<MyReactBootstrapButton />, document.getElementById("myBtn"));
</script>

工作Fiddlelink:fiddle