|
|
@@ -0,0 +1,66 @@
|
|
|
+<!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>
|
|
|
+ .head {
|
|
|
+ color: orange;
|
|
|
+ }
|
|
|
+
|
|
|
+ .aa {
|
|
|
+ color: red;
|
|
|
+ }
|
|
|
+
|
|
|
+ .bb {
|
|
|
+ font-style: italic;
|
|
|
+ }
|
|
|
+
|
|
|
+ .cc {
|
|
|
+ text-decoration: underline;
|
|
|
+ }
|
|
|
+
|
|
|
+ .dd {
|
|
|
+ background: #ff0;
|
|
|
+ }
|
|
|
+
|
|
|
+ .ee {
|
|
|
+ background: #00f;
|
|
|
+ }
|
|
|
+ </style>
|
|
|
+ <!-- <link rel="stylesheet" href="./css/b.css" precedence="high">
|
|
|
+ <link rel="stylesheet" href="./css/a.css" precedence="low"> -->
|
|
|
+</head>
|
|
|
+
|
|
|
+<body>
|
|
|
+ <div id="root"></div>
|
|
|
+ <script type="text/babel">
|
|
|
+
|
|
|
+ const news = 'aa';
|
|
|
+ const isActive = false;
|
|
|
+ const other = ['aa', 'cc', isActive ? 'dd' : 'ee']
|
|
|
+ const element = (
|
|
|
+ <div>
|
|
|
+ {/* 单个类名 */}
|
|
|
+ <h1 className='head'>Class样式绑定</h1>
|
|
|
+ {/* 多个类名:字符串 */}
|
|
|
+ <h3 className={'aa bb'}>哈哈哈</h3>
|
|
|
+ {/* 多个类名:模版字符串 */}
|
|
|
+ <div className={`${news} ${isActive ? 'bb' : 'cc'}`}>大家好</div>
|
|
|
+ {/* 多个类名:数组 + join() */}
|
|
|
+ <div className={other.join(' ')}>endeing</div>
|
|
|
+ <div className='end'>最后</div>
|
|
|
+ </div>
|
|
|
+ )
|
|
|
+ const container = document.getElementById("root");
|
|
|
+ const root = ReactDOM.createRoot(container)
|
|
|
+ root.render(element);
|
|
|
+ </script>
|
|
|
+</body>
|
|
|
+
|
|
|
+</html>
|