輕量級的,客戶端路由庫:PathJS
PathJS 是個輕量級的,客戶端路由庫,允許你創建 “單頁”應用,使用 Hashbangs 和/或者 HTML5 pushState。
主要特性:
-
輕量級
-
支持 HTML5 History API, 'onhashchange' 方法和平滑的 degredation
-
支持根路由,rescue methods, paramaterized routes, optional route components (dynamic routes), and Aspect Oriented Programming
-
經過了很好的測試 (測試示例請看
./tests
目錄) -
兼容所有主流瀏覽器(通過了 Firefox 3.6, Firefox 4.0, Firefox 5.0, Chrome 9, Opera 11, IE7, IE8, IE9 的測試)
-
獨立于所有第三方庫,但是又能很好的與第三方庫結合使用
簡單示例:
function clearPanel(){ // You can put some code in here to do fancy DOM transitions, such as fade-out or slide-in. } Path.map("#/users").to(function(){ alert("Users!"); }); Path.map("#/comments").to(function(){ alert("Comments!"); }).enter(clearPanel); Path.map("#/posts").to(function(){ alert("Posts!"); }).enter(clearPanel); Path.root("#/posts"); Path.listen();
本文由用戶 jopen 自行上傳分享,僅供網友學習交流。所有權歸原作者,若您的權利被侵害,請聯系管理員。
轉載本站原創文章,請注明出處,并保留原始鏈接、圖片水印。
本站是一個以用戶分享為主的開源技術平臺,歡迎各類分享!