diff --git a/src/App.js b/src/App.js
index fb90132..5d2ab59 100644
--- a/src/App.js
+++ b/src/App.js
@@ -3,71 +3,97 @@ import React from "react";
import './App.css';
function App() {
- // vue3 组合式 API
- // React 必须大写 Pascal 命名 组件
- function FnHello({name="Fn"}){
- return
Hello world By {name}
- }
-
- let com = FnHello({name:"obj"})
-
- function FnHello2(){
- return React.createElement("div", [], "Hello world By React.createElement")
- }
-
- // vue2 选项式 API
- class ClassHello extends React.Component {
- // eslint-disable-next-line no-useless-constructor
- constructor(props) {
- super(props);
+ // vue3 组合式 API
+ // React 必须大写 Pascal 命名 组件
+ function FnHello({name = "Fn"}) {
+ return Hello world By {name}
}
- render() {
- return Hello world By Class
+ let com = FnHello({name: "obj"})
+
+ function FnHello2() {
+ return React.createElement("div", [], "Hello world By React.createElement")
}
- }
- // React 不能直接渲染 js 对象
- let obj = {
- a: 1,
- b: 2
- }
+ // vue2 选项式 API
+ class ClassHello extends React.Component {
+ // eslint-disable-next-line no-useless-constructor
+ constructor(props) {
+ super(props);
+ }
- // 如果是数组则依次遍历
- let arr1 = [
- 1,
- 2,
- 3
- ]
+ render() {
+ return Hello world By Class
+ }
+ }
- let arr2 = [
- FnHello({name:"arr1"}),
- FnHello({name:"arr2"}),
- FnHello({name:"arr3"}),
- ]
+ // React 不能直接渲染 js 对象
+ let obj = {
+ a: 1,
+ b: 2
+ }
- return (
-
-
- {/*
*/}
-
+ // 如果是数组则依次遍历
+ let arr1 = [
+ 1,
+ 2,
+ 3
+ ]
-
+ let arr2 = [
+ FnHello({name: "item1"}),
+ FnHello({name: "item2"}),
+ FnHello({name: "item3"}),
+ ]
-
+ function clickHandler2() {
+ console.log("按钮2被点击")
+ }
- {com}
+ function clickHandler3(arg, e) {
+ console.log("按钮3被点击, 参数 " + arg)
+ console.log("合成的事件对象", e)
+ // 阻止事件冒泡
+ e.stopPropagation()
+ }
- {JSON.stringify(obj)}
+ return (
+
+
+ {/*
*/}
+
-
+
- {arr1}
+
- {arr2}
-
-
- );
+ {com}
+
+ {JSON.stringify(obj)}
+
+
+
+ {arr1}
+
+ {arr2}
+
+
+
+ {/*事件绑定*/}
+
+
+
+
+
+
+
+
+
+
+ );
}
export default App;