前言:非常鐘情ant pro所以想著把react先入門了俭令,之前了解過vue,所以繼續(xù)加油
js下載
- https://cdn.staticfile.org/react/16.4.0/umd/react.development.js
- https://cdn.staticfile.org/react-dom/16.4.0/umd/react-dom.development.js
- https://unpkg.com/babel-standalone@6.15.0/babel.min.js
上手第一次
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Title</title>
<div id="example1"></div>
<div id="example2"></div>
</head>
<body>
<script type="text/javascript" src="../react.development.js"></script>
<script type="text/javascript" src="../react-dom.development.js"></script>
<script type="text/javascript" src="../babel.min.js"></script>
<script type="text/babel">
//1.0定義組件 工廠函數(shù)方式
function Mycomponent() {
return <h3>Hello my first react</h3>
}
//1.1利用react.dom形式
class Myconpoent2 extends React.Component{
render(){
return <h3>Es6 組件實(shí)現(xiàn)</h3>
}
}
//2.渲染組件標(biāo)簽
ReactDOM.render(<Mycomponent />,document.getElementById('example1'));
ReactDOM.render(<Myconpoent2 />,document.getElementById('example2'));
</script>
<!--//2.渲染組織-->
</body>
</html>
報(bào)錯(cuò)
Super expression must either be null or a function, not undefined
- 解決把1.1中的React寫成了ReactDOM