-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.html
64 lines (55 loc) · 1.72 KB
/
index.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8" />
<title>Hello World</title>
<!--react的核心库-->
<script src="https://unpkg.com/react@16/umd/react.development.js"></script>
<!--react-dom的库 提供操作dom的方法;渲染react页面-->
<script src="https://unpkg.com/react-dom@16/umd/react-dom.development.js"></script>
<!--编译jsx 这个js是用于开发环境,生产环境(交付给用户)不能使用这个-->
<!--
使用这个文件进行编译jsx,只能用于开发,他的效率太慢,因为编译在本地,
需要每一次都编译,使用构建工具可以进行编译,这样编译出来的文件可以直接使用
-->
<script src="https://unpkg.com/babel-standalone@6.15.0/babel.min.js"></script>
</head>
<body>
<div id="root"></div>
<script type="text/babel">
// let ele = <h1>Hello, world!</h1>;
/*
组件1的定义方法 ES5
function Show(props){
return <h1>Hello, world! {props.name}</h1>
}
*/
class TestCom1 extends React.Component{
render(){
return <h1>Hello,{this.props.name}</h1>
};
};
class TestCom2 extends React.Component{
render(){
return <h1>Hello,{this.props.age}</h1>
};
};
class App extends React.Component{
render(){
return(
<div>
<TestCom1 name = "kaka"/>
<TestCom2 age = "22"/>
</div>)
}
}
/* let ele1 = <TestCom1 name = "kaka"/>;
let ele2 = <TestCom2 age = '22' />;*/
let ele = <App/>;
ReactDOM.render(
ele,
document.getElementById('root')
);
</script>
</body>
</html>