我似乎无法解决这个极其简单的问题。
我有一个Backbone/Marionnette应用程序,其中我将路由器定义为:
app.utils.AppRouter = Backbone.Marionette.AppRouter.extend({
initialize: function(){
this.route("", "home", function(){
console.log("In home!");
app.layout.content.show(new app.views.BrowseRestaurantsLayout());
});
this.route("account", "account", function(){
console.log("In account!");
app.layout.content.show(new app.views.AccountView());
});
}
});在代码中的其他地方,我需要导航到#account页面,所以我调用:
app.router.navigate('account', {trigger:true});我可以看到网址更改为#account,我的AccountView页面确实出现了一瞬间,然后消失,并被主页取代。
当我触发更改时,控制台显示为:
In account!
In home! 我遗漏了什么?
发布于 2012-08-10 04:05:22
您的主路由可能是一个包罗万象的路由,它是在您的帐户路由之后调用的。
当您将路由更改为此路径时会发生什么情况?
this.route("/", "home", function(){
console.log("In home!");
app.layout.content.show(new app.views.BrowseRestaurantsLayout());
});或者这可能是路线的顺序。最后尝试添加家庭路由器。
https://stackoverflow.com/questions/11890839
复制相似问题