【发布时间】: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;
【问题讨论】:
-
看起来不错。把它作为一个答案并接受它,这样问题就不会再没有答案了。
-
好吧,不知道我可以回答我自己的问题。