Javascript 主干js子计算机

Javascript 主干js子计算机,javascript,backbone.js,Javascript,Backbone.js,如何为主干应用程序创建子计算机? 我找到了一些代码,但无法使其工作()。路由器创建后不会执行路由处理程序。最后将其添加到构造函数中 // grab the full URL var hash = Backbone.history.getHash(); // check if there is already a part of the URL that this subview cares about... var hashPart = hash.substr(prefix.length +

如何为主干应用程序创建子计算机?
我找到了一些代码,但无法使其工作()。路由器创建后不会执行路由处理程序。

最后将其添加到构造函数中

// grab the full URL
var hash = Backbone.history.getHash();

// check if there is already a part of the URL that this subview cares about...
var hashPart = hash.substr(prefix.length + 1, hash.length);

// ...if so, trigger the subroute immediately.  this supports the case where 
// a user directly navigates to a URL with a subroute on the first page load.
if (hashPart && hashPart != "") {
    Backbone.history.loadUrl(prefix + hashPart);
}