使用 router.route 时不会触发页面加载时的初始骨干路由
这有效。
Admin.Routers.AppRouter = Backbone.Router.extend({
// home() gets trigger when I visit http://example.com/admin
routes: {
"admin": "home"
},
initialize: function() {},
home: function() {
log("Home");
}
});
这不起作用。
Admin.Routers.AppRouter = Backbone.Router.extend({
initialize: function() {
var that = this;
// home() DOES NOT get trigger when I visit http://example.com/admin
this.route(/^\/admin$/, "home", function() {
that.home();
});
},
home: function() {
log("Home");
}
});
这是 router.route 的正确功能吗?
This works.
Admin.Routers.AppRouter = Backbone.Router.extend({
// home() gets trigger when I visit http://example.com/admin
routes: {
"admin": "home"
},
initialize: function() {},
home: function() {
log("Home");
}
});
This does not work.
Admin.Routers.AppRouter = Backbone.Router.extend({
initialize: function() {
var that = this;
// home() DOES NOT get trigger when I visit http://example.com/admin
this.route(/^\/admin$/, "home", function() {
that.home();
});
},
home: function() {
log("Home");
}
});
Is this the correct functionality of router.route?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
我假设您根据您发布的示例网址使用
{pushState: true}
。你可以尝试以下方法吗?I'm assuming you're using
{pushState: true}
based on the example urls you have posted. Can you try the following?