1.基础语法
1.引入三个文件
react.development.js
react-dom.development.js
babel.min.js
这三个地址,将得到的页面全选后复制粘贴到本地的文件中,分别对应react.js、react-dom.js和browser.min.js三个文件
<script src="./js/react.development.js"></script>
<script src="./js/react-dom.development.js"></script>
<script src="./js/babel.min.js"></script>
<div id="test"></div>
2.创建一个虚拟dom对象
// <!-- 创建虚拟dom元素对象 -->
var vDom=<h1>hello react</h1>
3.将虚拟dom渲染到页面真实dom容器中
ReactDOM.render(vDom,document.getElementById("test"))
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
</head>
<body>
<div id="test"></div>
<script type="text/javascript" src="./js/react.development.js"></script>
<script type="text/javascript" src='./js/react-dom.development.js'></script>
<script type="text/javascript" src="./js/babel.min.js"></script>
<script type="text/babel">
var vDom = <h1>hello react</h1>
ReactDOM.render(vDom, document.getElementById("test"))
</script>
</body>
</html>