我是新尝试在骨干网中使用路由器,但我的Backbone.history.start()
方法不起作用。它给了我以下错误
Uncaught TypeError: Cannot call method 'start' of undefined
这是我的代码
(function ($) {
window.App = {
Models: {},
Collections: {},
Views: {},
Router: {}
};
window.Template = function (id) {
return _.template( $('#' + id).html() );
};
App.Router = Backbone.Router.extend({
routers: {
'': 'index'
},
index: function () {
console.log('index page');
}
});
var r = new App.Router;
Backbone.history.start();
})(jQuery);
如何消除此错误?