【发布时间】:2017-11-09 03:09:33
【问题描述】:
我有以下代码,保存格式为 .html (index.html)。
我现在正在学习 React,当我在浏览器中执行这个 html 文件时,什么也没有发生。
我想知道这两行代码应该放在哪里或如何调用它们(执行渲染)。
如果我使用的是 mac,我在哪里可以找到 ./lib 中的文件?
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<title>Introduction | Learning React</title>
<link rel="stylesheet" href="lib/style.css" />
</head>
<body>
<section id="entry-point"></section>
<!-- Wifi might be spotty, so we've downloaded these to `./lib` -->
<script src="lib/react.js"></script>
<script src="lib/react-dom.js"></script>
<script type="text/javascript">
// Intentionally blank. Your walk-through code will go here
var hello = React.createElement('p', null, 'Hello, World!');
// Checkout what this does by opening your HTML file in the browser
ReactDOM.render(hello, document.getElementById('entry-point'));
</script>
</body>
</html>
【问题讨论】:
标签: javascript html react-native reactive-programming