包下载
npm install react react-dom -S
npm install babel -D
babel
Babel主要用途是一个JavaScript转换器,它可以转换各种ES代码为浏览器可识别的ES代码
在React里作为JSX语句转换器
html代码
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<title>Document</title>
<script src="./node_modules/react/umd/react.development.js"></script>
<script src="./node_modules/react-dom/umd/react-dom.development.js"></script>
<script src="./node_modules/babel-standalone/babel.js"></script>
</head>
<body>
<div id="app"></div>
<script type="text/babel">
let oDiv = document.getElementById('app');
ReactDOM.render(
<h4>Hello World!</h4>,
oDiv
);
</script>
</body>
</html>