【发布时间】:2015-07-23 20:49:11
【问题描述】:
我正在尝试学习 react.js,但被“Hello World”脚本卡住了。
我的 index.html:
<!DOCTYPE html>
<html>
<head>
<script src="https://fb.me/react-0.13.3.js"></script>
<script src="https://fb.me/JSXTransformer-0.13.3.js"></script>
</head>
<body>
<div id="example"></div>
<script type="text/jsx" src="src/helloworld.js"></script>
</body>
</html>
和 src/helloworld.js:
React.render(
<h1>Hello, world!</h1>,
document.getElementById('example')
);
当我将此代码放在index.html 文件中的<script> 中时,它可以正常工作,但是当我将其移动到单独的文件时,我得到空白页和控制台错误:
XMLHttpRequest cannot load file:///home/marcin/Projects/react/src/helloworld.js. Cross origin requests are only supported for protocol schemes: http, data, chrome, chrome-extension, https, chrome-extension-resource.
这有什么问题?
【问题讨论】:
标签: javascript html reactjs