-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.html
62 lines (60 loc) · 2.15 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
<!doctype html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>study-React-01-jdapp</title>
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0, user-scalable=no">
</head>
<body>
<div id="app"></div>
<script src="./dist/bundle.js"></script>
<div id="banner"></div>
<script type="text/babel">
class Banner extends React.Component{
constructor(props){
super(props);
this.state={
count:0
}
this.handleMouseEnter=this.handleMouseEnter.bind(this)
this.handleMouseOut=this.handleMouseOut.bind(this)
}
componentDidMount(){
timer()
}
var timer;//设为全局很抱歉;
timer(){
timer=setTimeout(tick(),1000);
}
tick(){
this.setState(function(d){
count:++d;
}
)
}
handleMouseEnter(){
clearTimeout(timer)
}
handleMouseOut(){
timer();
}
render(){
var i_src=".jpg";
imgstyle={
float:"left";
}
var images=[];
for(var i=0;i<banner图的个数;i++)
image.push(<img src=i+i_src key=i style={imgstyle} onMouseEnter={this.handleMouseEnter}/>)
return(
<div style={{overflow:"hidden",width:"一张banner的宽度,后边改的人自己改一下哦!"}}
{images[this.state.count%(banner图个数])}//
</div>
)
}
}
}
</script>
</body>
</html>