I'm trying to learn react.js, but got stuck on "Hello World" script.
My 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>
and src/helloworld.js:
React.render(
<h1>Hello, world!</h1>,
document.getElementById('example')
);
When I put this code inside <script>
in index.html
file it works fine, but when I move it to seperate file I get blank page, and console error:
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.
What is wrong with it?
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…