【发布时间】:2012-02-15 23:21:26
【问题描述】:
我可以在backbone.js 中使用多个路由器,它们不会在路由方面相互干扰,没有任何问题吗?或者有什么我应该关心的吗?
代码示例:
myapp.routers.main = Backbone.Router.extend({
routes : { "": "index" },
index : function() { console.log("routed by main router");}
});
myapp.routers.another = Backbone.Router.extend({
routes : { "notmain": "index" },
index : function() { console.log("routed by another router");}
});
mainrouter = new vaikava.routers.main;
notmainrouter = new vaikava.routers.another;
Backbone.history.start();
【问题讨论】:
-
回答这个问题的最简单方法是尝试一下,看看它是否有效。据我所知,您所概述的内容应该没有问题。
-
我自己尝试过 - 没有错误,但由于这是我的第一个真正的主干应用程序,而且我读到多个路由器可能存在问题,我想在这里问一下
标签: backbone.js router