我有一个使用require js
. 一切对我来说似乎都很好,但它不起作用。我router
从我的电话app.js
:
路由器JS:
define([
'jquery',
'underscore',
'backbone',
'view/questions/index'
], function($, _, Backbone, IndexView){
var AppRouter = Backbone.Router.extend({
routes: {
'/': 'index'
}
});
var initialize = function(){
var app_router = new AppRouter();
// Index Route
app_router.on('index', function(){
var indexView = new IndexView();
console.log('test');
indexView.initialize();
});
// Default Route
app_router.on('defaultAction', function(actions){
console.log('No Route', actions);
});
Backbone.history.start();
};
return {
initialize: initialize
};
});
应用程序JS:
define([
'jquery',
'underscore',
'backbone',
'router'
], function($, _, Backbone, Router){
var initialize = function(){
Router.initialize();
};
return {
initialize: initialize
};
});