我正在尝试学习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>
Run Code Online (Sandbox Code Playgroud)
和src/helloworld.js:
React.render(
<h1>Hello, world!</h1>,
document.getElementById('example')
);
Run Code Online (Sandbox Code Playgroud)
当我里面把这个代码<script>在index.html文件中它工作正常,但是当我将其移动到单独的文件中我得到的空白页,并控制台错误:
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.
这有什么问题?