如果我使用 Require.js 来管理带有 Backbone.js(也有下划线)的项目中的模块,那么在扩展模块时我可以做这样的事情
require(['Home'], function(home) {
'use strict';
var view = home.View.prototype;
_.extend(view,{
anotherTitle: 'Welcome Jean Luc Picard';
});
});
或者
require(['Home'], function(home) {
'use strict';
var view = home.View.prototype;
view.anotherTitle= 'Welcome Jean Luc Picard'; //this is a new attribute
});
最合适的方法是什么?