0
我是Backbone.js的新手,並不完全瞭解某些類型的路由器實現之間的區別。Backbone.js路由器實現
1.類型:
var Workspace = Backbone.Router.extend({
routes:{
'*filter': 'setFilter'
},
setFilter: function(param) {
// Set the current filter to be used
Common.TodoFilter = param.trim() || '';
// Trigger a collection filter event, causing hiding/unhiding
// of the Todo view items
Todos.trigger('filter');
}
});
2.類型:
var AppRouter = Backbone.Router.extend({
routes: {
// default
'*actions': 'defaultAction'
}
});
var initialize = function() {
var router = new AppRouter();
router.on('route:defaultAction', function(actions) {
var homeView = new HomeView();
homeView.render();
});
Backbone.history.start();
};
return {
initialize: initialize
};
那麼,就是在1型和功能router.on正常回調(使用setfilter)之間的差('route:defaultAction',function(actions)?
感謝您的解釋 – Potty