使用核心 Backbone 路由器时,有没有简单的方法去掉url中的“#”?现在我有一个如下所示的网址:somesite.com/#some_back_bone_route/:blog_title
我想要:somesite.com/some_back_bone_route/:blog_title
。这可能吗?
我看过的所有地方都没有真正给出关于如何实现这一目标的明确答案或方向,甚至没有说明是否可能,即使文档围绕这个主题也令人困惑。
想法?
最佳答案
根据我上面的评论,使用现代浏览器(和历史记录 API),可以不在 URL 中使用哈希值。看看http://backbonejs.org/#Router (关键字:pushState
)。
但此方法有一些注意事项:您的后端可能需要是 changed .
Note that using real URLs requires your web server to be able to correctly render those pages, so back-end changes are required as well. For example, if you have a route of /documents/100, your web server must be able to serve that page, if the browser visits that URL directly.
关于javascript - 删除主干路由中的 "#",我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/27558104/