V2EX = way to explore
V2EX 是一个关于分享和探索的地方
现在注册
已注册用户请  登录
V2EX 提问指南
mechille
V2EX  ›  问与答

js 能写 URL 路由么?

  •  
  •   mechille · 2014-03-20 14:53:49 +08:00 · 3156 次点击
    这是一个创建于 3694 天前的主题,其中的信息可能已经有所发展或是发生改变。
    看到过卜卜口用「hash实现换页不刷新」最终路径是

    url/abc/#!19d7b39 这样的

    如果配合rewrite有没有可能实现只考js(jquery)写一个路由格式像这样

    url/abc/19d7b39
    7 条回复    1970-01-01 08:00:00 +08:00
    66beta
        1
    66beta  
       2014-03-20 15:03:32 +08:00
    用js又不刷新的话,要在iframe里面做了吧
    haiyang416
        2
    haiyang416  
       2014-03-20 15:04:44 +08:00   ❤️ 1
    不太理解楼主所指的路由需要那些功能,不过之前看过一篇文章讲过url修改的内容。
    http://www.ruanyifeng.com/blog/2013/07/how_to_make_search_engines_find_ajax_content.html
    mechille
        3
    mechille  
    OP
       2014-03-20 15:06:36 +08:00
    @haiyang416 正是我想要的东西,非常感谢
    learnshare
        4
    learnshare  
       2014-03-20 15:08:26 +08:00
    Angular 有这个模块,或者自己通过 history.pushState 自己写一下这个模块
    RIcter
        5
    RIcter  
       2014-03-20 16:02:24 +08:00
    我曾经不用Angular只基于jquery写了个和卜卜类似的。。
    结果是其他都还好,在V那里js和html耦合的紧而且复用率为0....
    还是用了Angular..

    看了下这个是History api...
    赞( ̄▽ ̄),http://gather.whouz.com 就是用这个..
    YuHong
        6
    YuHong  
       2014-03-20 16:04:07 +08:00
    Tiny ~1200 byte Express-inspired client-side router.

    https://github.com/visionmedia/page.js
    cyr1l
        7
    cyr1l  
       2014-03-20 22:55:26 +08:00
    html5 history
    关于   ·   帮助文档   ·   博客   ·   API   ·   FAQ   ·   我们的愿景   ·   实用小工具   ·   1001 人在线   最高记录 6543   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 24ms · UTC 23:22 · PVG 07:22 · LAX 16:22 · JFK 19:22
    Developed with CodeLauncher
    ♥ Do have faith in what you're doing.