|
@@ -0,0 +1,48 @@
|
|
|
|
|
+<!DOCTYPE html>
|
|
|
|
|
+<html lang="en">
|
|
|
|
|
+
|
|
|
|
|
+<head>
|
|
|
|
|
+ <meta charset="UTF-8">
|
|
|
|
|
+ <meta name="viewport" content="width=device-width, initial-scale=1.0">
|
|
|
|
|
+ <title>Document</title>
|
|
|
|
|
+ <script src="./babel.min.js"></script>
|
|
|
|
|
+ <script src="./react.development.js"></script>
|
|
|
|
|
+ <script src="./react-dom.development.js"></script>
|
|
|
|
|
+</head>
|
|
|
|
|
+
|
|
|
|
|
+<body>
|
|
|
|
|
+ <div id="root"></div>
|
|
|
|
|
+ <script type="text/babel">
|
|
|
|
|
+ let root = ReactDOM.createRoot(document.getElementById("root"));
|
|
|
|
|
+ /**
|
|
|
|
|
+ * 组件:
|
|
|
|
|
+ * 1.函数组件
|
|
|
|
|
+ * 2.类组件
|
|
|
|
|
+ */
|
|
|
|
|
+ // 函数组件只能有一个根节点 大驼峰命名法
|
|
|
|
|
+ function HelloWorld() {
|
|
|
|
|
+ return (
|
|
|
|
|
+ <div>
|
|
|
|
|
+ <h1>你好</h1>
|
|
|
|
|
+ </div>
|
|
|
|
|
+ // <div></div>
|
|
|
|
|
+ )
|
|
|
|
|
+ }
|
|
|
|
|
+ // 类组件只能有一个根节点 大驼峰命名法
|
|
|
|
|
+ // 必须用render渲染页面
|
|
|
|
|
+ // 必须继承React.Component
|
|
|
|
|
+ class EveryDay extends React.Component {
|
|
|
|
|
+ render() {
|
|
|
|
|
+ return (
|
|
|
|
|
+ <div>
|
|
|
|
|
+ <h1>哈哈哈哈</h1>
|
|
|
|
|
+ </div>
|
|
|
|
|
+ // div
|
|
|
|
|
+ )
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ root.render(<EveryDay />);
|
|
|
|
|
+ </script>
|
|
|
|
|
+</body>
|
|
|
|
|
+
|
|
|
|
|
+</html>
|