|
|
@@ -0,0 +1,51 @@
|
|
|
+<!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>
|
|
|
+ <style>
|
|
|
+ .news {
|
|
|
+ color: red;
|
|
|
+ }
|
|
|
+ .other {
|
|
|
+ font-size: 40px;
|
|
|
+ }
|
|
|
+ </style>
|
|
|
+</head>
|
|
|
+
|
|
|
+<body>
|
|
|
+ <!--
|
|
|
+ 样式绑定:
|
|
|
+ style:在jsx中直接定义
|
|
|
+ class: 样式表中定义 通过className使用
|
|
|
+ -->
|
|
|
+ <div id="root"></div>
|
|
|
+ <script type="text/babel">
|
|
|
+ let root = ReactDOM.createRoot(document.getElementById("root"));
|
|
|
+ let element = <div>
|
|
|
+ <div className='news'>哪吒</div>
|
|
|
+ <div className={'news other'}>孙悟空</div>
|
|
|
+ </div>
|
|
|
+ const vase = {
|
|
|
+ color: 'blue',
|
|
|
+ fontSize: '40px',
|
|
|
+ fontWeight: 'bold'
|
|
|
+ }
|
|
|
+ element = <p style={vase}>哈哈哈哈</p>
|
|
|
+ const one = {
|
|
|
+ color: 'pink'
|
|
|
+ }
|
|
|
+ const two = {
|
|
|
+ color: 'green'
|
|
|
+ }
|
|
|
+ element = <div style={5 > 2 ? one : two}>你好</div>
|
|
|
+ root.render(element);
|
|
|
+ </script>
|
|
|
+</body>
|
|
|
+
|
|
|
+</html>
|