path.js 简单 轻量级的 Web 浏览器路由库
PathJS 是一个轻量级的客户端路由库,允许您使用 hash 或者是 HTML5 pushState 创建 SPA 单页应用程序。
特点
- 简单轻量级
- 全面支持 HTML5 History API,如果浏览器不支持,可以优雅的降级使用普通链接。
- 支持 根路由、救援方法、参数化路由、可选路由组件(动态路由)和面向对象的编程
- 兼容所有主流浏览器(在 Firefox 3.6、Firefox 4.0、Firefox 5.0、Chrome 9、Opera 11、IE7、IE8、IE9 上测试)
- 独立于所有第三方库,但对所有第三方库都很好的兼容
使用 PathJS
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();
Github 地址:https://github.com/mtrpcic/pathjs
如果你对这篇文章有疑问,欢迎到本站 社区 发帖提问或使用手Q扫描下方二维码加群参与讨论,获取更多帮助。


目前还没有任何评论,快来抢沙发吧!
发布评论
需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。