PathJS輕量級 Web 瀏覽器路由
PathJS 是個輕量級的,客戶端路由庫,允許你創(chuàng)建 “單頁”應用,使用 Hashbangs 和/或者 HTML5 pushState。
主要特性:
輕量級
支持 HTML5 History API, 'onhashchange' 方法和平滑的 degredation
支持根路由,rescue methods, paramaterized routes, optional route components (dynamic routes), and Aspect Oriented Programming
經(jīng)過了很好的測試 (測試示例請看
./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();
評論
圖片
表情
