各位编码员:)
所以我刚开始学习 ReactJs,在前 20 分钟就遇到了这个错误:
browser.js:62790 Uncaught SyntaxError: embedded: Unexpected token (9:3)
7 | </div>
8 | },
> 9 | )};
| ^
10 | React.render(<HelloWorld />, document.body);
11 |
我的代码如下:
<!DOCTYPE html>
<html>
<head>
<script src="https://fbcdn-dragon-a.akamaihd.net/hphotos-ak-xpa1/t39.3284-6/11057025_805715566176382_77439371_n.js"></script>
<!-- version 0.13.3.min.js-->
<script src="https://cdnjs.cloudflare.com/ajax/libs/babel-core/5.8.29/browser.js"></script>
<title>React</title>
</head>
<body>
<script type="text/babel">
var HelloWorld = React.createClass({
render: function() {
return <div>
<h1>Hello World</h1>
<p>This is some text</p>
</div>
}
)};
React.render(<HelloWorld />, document.body);
</script>
</body>
</html>
环顾四周,没有发现任何可以解决这个问题的东西。有什么想法吗?我确信这是一件简单的事情,但我才刚刚开始。
提前致谢!
最佳答案
你的括号有点偏离,请参阅组件定义的最后一行:
var HelloWorld = React.createClass({
render: function() {
return <div>
<h1>Hello World</h1>
<p>This is some text</p>
</div>
}
});
关于reactjs - React/Babel 嵌入 : unexpected token,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38512776/