|
@@ -0,0 +1,50 @@
|
|
|
|
|
+<!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>
|
|
|
|
|
+ <!--
|
|
|
|
|
+ 数据绑定:{} 表达式
|
|
|
|
|
+ 不能渲染的类型:
|
|
|
|
|
+ boolean undefined null
|
|
|
|
|
+ 不能使用 if/while/for
|
|
|
|
|
+ 可以使用:
|
|
|
|
|
+ 数学表达式
|
|
|
|
|
+ 三元表达式
|
|
|
|
|
+ 方法的调用
|
|
|
|
|
+ 数组的操作
|
|
|
|
|
+ -->
|
|
|
|
|
+ <script type="text/babel">
|
|
|
|
|
+ const userName = 'tutu';
|
|
|
|
|
+ const age = 3;
|
|
|
|
|
+ const arr = [1, 23, 4]
|
|
|
|
|
+ const obj = {
|
|
|
|
|
+ a: 1
|
|
|
|
|
+ }
|
|
|
|
|
+ function aa() { return 1 };
|
|
|
|
|
+ // const element = <h1>我叫{'123'}</h1>;
|
|
|
|
|
+ // const element = <h1>{
|
|
|
|
|
+ // age > 3 ? '大孩子' : '小孩子'
|
|
|
|
|
+ // }</h1>
|
|
|
|
|
+ const element = <h1>{
|
|
|
|
|
+ [...arr].reverse().join('')
|
|
|
|
|
+ }</h1>
|
|
|
|
|
+ // const element = <h1>{aa()}</h1>
|
|
|
|
|
+ // const element = <h1>{12}</h1>
|
|
|
|
|
+ // const element = <h1>我叫{userName},今年{age + 10}岁</h1>
|
|
|
|
|
+ const container = document.getElementById("root");
|
|
|
|
|
+ const root = ReactDOM.createRoot(container)
|
|
|
|
|
+ root.render(element);
|
|
|
|
|
+ </script>
|
|
|
|
|
+</body>
|
|
|
|
|
+
|
|
|
|
|
+</html>
|