Skip to content

Commit 8122115

Browse files
committed
Merge pull request AngelCrunchDev#20 from kxxoling/master
Add director.js
2 parents 18f6de0 + a48b6b9 commit 8122115

File tree

1 file changed

+50
-0
lines changed

1 file changed

+50
-0
lines changed

frontend/director.rst

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
.. _director:
2+
3+
===========
4+
director.js
5+
===========
6+
7+
:作者: 王然 [email protected]
8+
9+
简介
10+
----
11+
12+
`director <https://github.com/flatiron/director#client-side-routing>`_ 提供前端和后端的
13+
路由解决方案,可以用于控制前端路由以及页面代码的显示与否。
14+
15+
使用很简单:
16+
17+
.. code-block:: html
18+
19+
<!DOCTYPE html>
20+
<html>
21+
<head>
22+
<meta charset="utf-8">
23+
<title>Director Example</title>
24+
<div id="results"></div>
25+
<script src="http://www.javascriptoo.com/application/html/js/flatiron/director/director.min.js"></script>
26+
<script>
27+
var r = document.getElementById('results');
28+
var data = {
29+
people: [
30+
{ 'firstName': 'Clark', 'lastName': 'Kent' },
31+
{ 'firstName': 'Bruce', 'lastName': 'Wayne' },
32+
{ 'firstName': 'Peter', 'lastName': 'Parker' }
33+
]
34+
}
35+
var viewPerson = function(personId) { r.innerHTML = data.people[personId].firstName + ' ' + data.people[personId].lastName; };
36+
var routes = {'/person/view/:bookId': viewPerson};
37+
var router = Router(routes);
38+
router.init();
39+
</script>
40+
</head>
41+
<body>
42+
<ul>
43+
<li><a href="#/person/view/0">Clark</a></li>
44+
<li><a href="#/person/view/1">Bruce</a></li>
45+
<li><a href="#/person/view/2">Peter</a></li>
46+
</ul>
47+
</body>
48+
</html>
49+
50+
效果预览: `GitHub Pages <http://angelcrunchdev.github.io/z42-doc/director>`_

0 commit comments

Comments
 (0)