forked from RubyLouvre/anu
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex8.html
91 lines (80 loc) · 2.35 KB
/
index8.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
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width">
<style>
.aaa {
width: 200px;
height: 200px;
background: red;
}
.bbb {
width: 200px;
height: 200px;
background: lawngreen;
}
</style>
<script type='text/javascript' src="./dist/React.js"></script>
<script type='text/javascript' src="./dist/devtools.js"></script>
<!-- <script src="./test/react.js"></script>
<script src="./test/react-dom.js"></script>-->
<script src="./test/redux.js"></script>
<script src="./test/react-redux.js"></script>
<script src="./test/babel.js"></script>
<script type='text/babel'>
var s
var str = ''
class Component1 extends React.Component {
componentWillUnmount() {
str += 'xxxx'
}
render() {
return <div className="component1">{this.props.children}</div>
}
}
class Component2 extends React.Component {
componentWillUnmount() {
str += ' yyyy'
}
render() {
return <div className="component1">xxx</div>
}
}
var index = 1
function detect(a) {
if (index === 1) {
// expect(typeof a).toBe('object')
} else {
// expect(a).toBeNull()
}
}
class App extends React.Component {
constructor(props) {
super(props)
this.handleClick = this.handleClick.bind(this)
}
handleClick() {
index = 0
this.forceUpdate()
}
render() {
return index ?
<div ref='a' onClick={this.handleClick.bind(this)}>
<Component1>
<p ref={detect}>这是子节点</p>
<Component2 />
</Component1>
</div> : <div>文本节点</div>
}
};
window.onload = function(){
s = ReactDOM.render( <App />, document.getElementById('example'))
}
</script>
</head>
<body>
<div>这个默认会被清掉</div>
<div id='example'></div>
</body>
</html>