Skip to content

Commit 46b1e2c

Browse files
committed
add some rough examples
1 parent b737817 commit 46b1e2c

File tree

2 files changed

+94
-0
lines changed

2 files changed

+94
-0
lines changed

Diff for: examples/bookDetail/index.html

+68
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,68 @@
1+
<!DOCTYPE html>
2+
<html>
3+
4+
<head>
5+
<meta charset="utf-8">
6+
<title>detail</title>
7+
<script src="../../dist/leopard.js"></script>
8+
</head>
9+
10+
<body>
11+
<div id="app"></div>
12+
<script type="text/javascript">
13+
var tpl = '<div>' +
14+
'<img alt=\"<%= alt_title %>\" src=\"<%= image %>\" />' +
15+
'<h3><a href=\"<%= alt %>\"><%= title %></a></h3>' +
16+
'<p><%= summary %></p>' +
17+
'<p>信息:</p>' +
18+
'<ul>' +
19+
'<% for (var attr in attrs) { %>' +
20+
'<li><%= attrs[attr] %></li> ' +
21+
'<% } %>' +
22+
'</ul>' +
23+
'<p>标签:</p>' +
24+
'<ol>' +
25+
'<% for (var i = 0; i < tags.length; i++) { %>' +
26+
'<li><%= tags[i].name %></li> ' +
27+
'<% } %>' +
28+
'</ol>' +
29+
'</div>'
30+
var detail = {
31+
"id": "1220562",
32+
"alt": "https:\/\/book.douban.com\/book\/1220562",
33+
"rating": { "max": 10, "average": "7.0", "numRaters": 282, "min": 0 },
34+
"author": [{ "name": "片山恭一" }, { "name": "豫人" }],
35+
"alt_title": "",
36+
"image": "https://img3.doubanio.com\/spic\/s1747553.jpg",
37+
"title": "满月之夜白鲸现",
38+
"mobile_link": "https:\/\/m.douban.com\/book\/subject\/1220562\/",
39+
"summary": "那一年,是听莫扎特、钓鲈鱼和家庭破裂的一年。说到家庭破裂,母亲怪自己当初没有找到好男人,父亲则认为当时是被狐狸精迷住了眼,失常的是母亲,但出问题的是父亲……。",
40+
"attrs": {
41+
"publisher": ["青岛出版社"],
42+
"pubdate": ["2005-01-01"],
43+
"author": ["片山恭一", "豫人"],
44+
"price": ["18.00元"],
45+
"title": ["满月之夜白鲸现"],
46+
"binding": ["平装(无盘)"],
47+
"translator": ["豫人"],
48+
"pages": ["180"]
49+
},
50+
"tags": [
51+
{ "count": 106, "name": "片山恭一" },
52+
{ "count": 50, "name": "日本" },
53+
{ "count": 42, "name": "日本文学" },
54+
{ "count": 30, "name": "满月之夜白鲸现" },
55+
{ "count": 28, "name": "小说" },
56+
{ "count": 10, "name": "爱情" },
57+
{ "count": 7, "name": "純愛" },
58+
{ "count": 6, "name": "外国文学" }
59+
]
60+
}
61+
62+
var html = Leopard(tpl, detail)
63+
document.getElementById('app').innerHTML = html
64+
65+
</script>
66+
</body>
67+
68+
</html>

Diff for: examples/listview/index.html

+26
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
<!DOCTYPE html>
2+
<html>
3+
4+
<head>
5+
<meta charset="utf-8">
6+
<title>list view</title>
7+
<script src="../../dist/leopard.js"></script>
8+
</head>
9+
10+
<body>
11+
<div id="app"></div>
12+
<script type="text/javascript">
13+
var tpl = 'Now I repeat: ' +
14+
'<ul>' +
15+
'<% for (var i = 0; i < 20; i++) { %>' +
16+
'<li><%= i %>: I am Leopard!</li>' +
17+
'<% } %>' +
18+
'</ul>'
19+
var html = Leopard(tpl)
20+
21+
document.getElementById('app').innerHTML = html
22+
23+
</script>
24+
</body>
25+
26+
</html>

0 commit comments

Comments
 (0)