File tree Expand file tree Collapse file tree 1 file changed +50
-0
lines changed Expand file tree Collapse file tree 1 file changed +50
-0
lines changed Original file line number Diff line number Diff line change 1+ .. _director :
2+
3+ ===========
4+ director.js
5+ ===========
6+
7+ 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 >`_
You can’t perform that action at this time.
0 commit comments