没有散​​列的骨干路由? [英] Backbone routes without hashes?

查看:12
本文介绍了没有散​​列的骨干路由?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在为当前项目使用主干.我想知道是否可以像 davis.js 那样在没有散列 # 的情况下进行路由.

I'm using backbone for a current project. I was wondering if it's possible to do routing without hashes #, like davis.js does.

谢谢!

推荐答案

需要开启pushState

You need to enable pushState

Backbone.history.start({pushState: true})

http://backbonejs.org/#Router

http://backbonejs.org/#History

如评论中所述,这仅适用于支持 pushState 的浏览器,不支持的浏览器将回退到 hash 方法.没有真正的方法可以解决这个问题,您可以为现代浏览器启用并回退或仅对所有浏览器使用哈希.

As noted in the comments this will only work for browsers that support pushState, browsers that don't will fall back to the hash method. There is no real way around this, you can enable for modern browser and fall back or just use hashes for all browsers.

这篇关于没有散​​列的骨干路由?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆