我是 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 中的普通回调 (setFilter) 和函数 router.on('route:defaultAction', function(actions) 有什么区别?