-
Notifications
You must be signed in to change notification settings - Fork 0
/
test13-mount.html
49 lines (49 loc) · 1.53 KB
/
test13-mount.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
<!DOCTYPE html>
<html lang="en">
<head>
<title></title>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
</head>
<body>
<div id="root"></div>
<script src="./build/react.js"></script>
<script src="./build/react-dom.js"></script>
<script src="./build/browser.min.js"></script>
<script src="./build/jquery.min.js"></script>
<script type="text/babel">
let Hello = React.createClass({
// 初始化
getInitialState: function () {
alert('init');
return {
opacity: 1.0,
fontSize: '12px'
}
},
render: function () {
return <div style={{opacity: this.state.opacity, fontSize: this.state.fontSize}}>Hello {this.props.name}</div>;
},
// 组件渲染前
componentWillMount: function () {
alert('will');
},
// 组件渲染后
componentDidMount: function () {
alert('did');
setTimeout(() => {
console.log(this)
this.setState({
opacity: 0.5,
fontSize: '44px'
})
}, 1000);
}
});
ReactDOM.render(
<Hello name='world' />,
document.getElementById('root')
)
</script>
</body>
</html>