|
@@ -0,0 +1,63 @@
|
|
|
|
|
+<!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>
|
|
|
|
|
+ .box1 {
|
|
|
|
|
+ width: 400px;
|
|
|
|
|
+ height: 400px;
|
|
|
|
|
+ background: #f00;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ .box2 {
|
|
|
|
|
+ width: 200px;
|
|
|
|
|
+ height: 200px;
|
|
|
|
|
+ background: #ff0;
|
|
|
|
|
+ }
|
|
|
|
|
+ </style>
|
|
|
|
|
+</head>
|
|
|
|
|
+
|
|
|
|
|
+<body>
|
|
|
|
|
+ <div id="root"></div>
|
|
|
|
|
+ <script type="text/babel">
|
|
|
|
|
+ const handleClick = () => {
|
|
|
|
|
+ console.log("你好")
|
|
|
|
|
+ }
|
|
|
|
|
+ const handleBox1 = () => {
|
|
|
|
|
+ console.log("1111")
|
|
|
|
|
+ }
|
|
|
|
|
+ const handleBox2 = (event) => {
|
|
|
|
|
+ console.log("222")
|
|
|
|
|
+ // event.stopPropagation();
|
|
|
|
|
+ }
|
|
|
|
|
+ const handleJump = (event) => {
|
|
|
|
|
+ console.log("da'yin")
|
|
|
|
|
+ event.preventDefault();
|
|
|
|
|
+ }
|
|
|
|
|
+ function WelCome() {
|
|
|
|
|
+ return (
|
|
|
|
|
+ <div>
|
|
|
|
|
+ <h1 onClick={handleClick}>欢迎光临</h1>
|
|
|
|
|
+ <h1 onClick={() => console.log('哈哈')}>欢迎光临2</h1>
|
|
|
|
|
+ <div className='box1' onClick={handleBox1}>
|
|
|
|
|
+ <div className='box2' onClick={handleBox2}>
|
|
|
|
|
+ </div>
|
|
|
|
|
+ </div>
|
|
|
|
|
+ <a href="http://www.baidu.com" onClick={handleJump}>跳转</a>
|
|
|
|
|
+ </div>
|
|
|
|
|
+ )
|
|
|
|
|
+ }
|
|
|
|
|
+ const element = <WelCome />
|
|
|
|
|
+ const container = document.getElementById("root");
|
|
|
|
|
+ const root = ReactDOM.createRoot(container)
|
|
|
|
|
+ root.render(element);
|
|
|
|
|
+ </script>
|
|
|
|
|
+</body>
|
|
|
|
|
+
|
|
|
|
|
+</html>
|