组件的诞生
2020-04-12 本文已影响0人
kzc爱吃梨
代码:http://jsbin.com/nezocuk/2/edit?html,js,output
- 简单组件用函数
- 第一个参数就是 props
- 复杂组件用 class
- constructor(props) super(props)
- this.state
- this.setState()
- render
</article>
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width">
<script src="https://cdnjs.cloudflare.com/ajax/libs/react/16.4.0/umd/react.production.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/react-dom/16.4.0/umd/react-dom.production.min.js"></script>
<title>JS Bin</title>
</head>
<body>
<div id="root"></div>
</body>
</html>