| 注册
请输入搜索内容

热门搜索

Java Linux MySQL PHP JavaScript Hibernate jQuery Nginx
jopen
9年前发布

JavaScript的URL路由:Director(Director.js)

Director(Director.js) 是个路由,当一个 URL 请求的时候可以决定代码在哪里运行。

Features

  • Client-Side Routing
  • Server-Side HTTP Routing
  • Server-Side CLI Routing

JavaScript的URL路由:Director(Director.js)

简单示例

<!DOCTYPE html>  <html>    <head>      <meta charset="utf-8">      <title>A Gentle Introduction</title>      <script        src="https://rawgit.com/flatiron/director/master/build/director.min.js">      </script>      <script>        var author = function () { console.log("author"); };        var books = function () { console.log("books"); };        var viewBook = function (bookId) {          console.log("viewBook: bookId is populated: " + bookId);        };        var routes = {          '/author': author,          '/books': [books, function() {            console.log("An inline route handler.");          }],          '/books/view/:bookId': viewBook        };        var router = Router(routes);        router.init();      </script>    </head>    <body>      <ul>        <li><a href="#/author">#/author</a></li>        <li><a href="#/books">#/books</a></li>        <li><a href="#/books/view/1">#/books/view/1</a></li>      </ul>    </body>  </html>

项目主页:http://www.open-open.com/lib/view/home/1435309264607

 本文由用户 jopen 自行上传分享,仅供网友学习交流。所有权归原作者,若您的权利被侵害,请联系管理员。
 转载本站原创文章,请注明出处,并保留原始链接、图片水印。
 本站是一个以用户分享为主的开源技术平台,欢迎各类分享!
 本文地址:https://www.open-open.com/lib/view/open1435309264607.html
JavaScript开发工具包 Director(Director.js)