-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.html
67 lines (66 loc) · 1.89 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
65
66
67
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<title>React Tutorial</title>
<script src="https://cdnjs.cloudflare.com/ajax/libs/react/0.14.0/react.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/react/0.14.0/react-dom.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/babel-core/5.8.23/browser.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
</head>
<body>
<div id="content"></div>
<script type="text/babel">
var data = [
{id:1,author:'L',text:'你好吗?'},
{id:2,author:'H',text:'very good'}
];
var CommentBox = React.createClass({
render:function(){
return(
<div className="commentBox">
<CommentList data={this.props.data} />
<CommentForm />
</div>
)
}
});
var CommentList = React.createClass({
render:function(){
var CommentNode = this.props.data.map(function(comment){
return(
<Comment key={comment.id} author={comment.author}>{comment.text}</Comment>
);
});
return(
<ul className="commentList" >
{CommentNode}
</ul>
)
}
});
var Comment = React.createClass({
render:function(){
return(
<li className="comment">
<span>{this.props.author}</span> : {this.props.children}
</li>
)
}
});
var CommentForm = React.createClass({
render:function(){
return(
<div className="commentForm">
form
</div>
)
}
});
ReactDOM.render(
<CommentBox data={data} />,
document.getElementById('content')
);
</script>
</body>
</html>