【问题标题】:Not able to get started with react-bootstrap无法开始使用 react-bootstrap
【发布时间】:2015-11-08 18:05:12
【问题描述】:

我刚开始使用 react,虽然一切正常,但我无法开始使用 react-bootstrap,这是我的 .html 文件的样子:

<html>
<head>    
<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> 
</head> 
<body>     
<script src="https://code.jquery.com/jquery-1.10.2.min.js"></script>
<script type="text/jsx" src="react-bootstrap.js"> </script>
<script type="text/jsx">
React.render(
 <p> test </p>
 <Button> test </Button>,
 document.body
);
</script> 
</body>
</html>

不起作用。

我收到一个解析错误:相邻的 JSX 元素必须包含在封闭标记中

非常感谢任何帮助。

更新:

问题已解决。

解决方案: 制作它:

React.render( <div> <p> test </p> <Button> test </Button> </div>,
    document.body) 

还要加,

var Button = ReactBootstrap.Button; 

【问题讨论】:

  • 看起来不错。把它作为一个答案并接受它,这样问题就不会再没有答案了。
  • 好吧,不知道我可以回答我自己的问题。

标签: reactjs react-bootstrap


【解决方案1】:

我找到了解决方案: React 需要一个根元素来渲染。所以,把它改成 -

React.render( <div> <p> test </p> <Button> test </Button> </div>,
    document.body) 

还要加,

var Button = ReactBootstrap.Button; 

【讨论】:

    猜你喜欢
    • 2014-06-27
    • 2010-10-22
    • 1970-01-01
    • 1970-01-01
    • 2017-11-19
    • 1970-01-01
    • 1970-01-01
    • 2016-01-05
    • 2013-02-09
    相关资源
    最近更新 更多