鉴于:
super.app
由 Backbone 提供支持的 Web 应用程序 Tom 浏览到
products/1
所在页面#special-offer
节存在。Backbone 是否允许 Tom 与 Fred 共享链接,包括特价部分的 anchor :http://super.app/products/1#special-offer
Fred 会被重定向到 http://super.app/#products/1 (例如:没有
#special-offer
)?换句话说,Backbone 允许使用 anchor 吗?
最佳答案
我在这里做了一个测试 http://bl.ocks.org/abernier/raw/3183257/
看来是的:
http://bl.ocks.org/abernier/raw/3183257/product1.html#special-offer
http://bl.ocks.org/abernier/raw/3183257/#product1.html
例如:没有 #special-offer
我唯一需要注意的是禁用基于哈希的历史浏览器的 anchor ,方法是:
if (!Backbone.history._hasPushState) {
$('body').delegate('a[href^=#]', 'click', function (e) {
e.preventDefault();
});
}
关于backbone.js - 链接中的 anchor ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11672687/