【发布时间】:2014-05-28 19:07:57
【问题描述】:
我无法访问我的“App”对象,尽管我在我的模块中使用定义的语句需要它。你能解释一下为什么我的代码不起作用。
这是我的 main.js 文件:
require(['underscore', 'backbone', 'App'], function(_, Backbone, App) {
window.App = new App();
Backbone.history.start();
return window.App.init();
});
这是我的 app.js 文件:
define(['underscore', 'backbone', 'Views/ApplicationView'], function(_, Backbone, ApplicationView) {
'use strict';
var App;
return App = (function() {
function App() {
this.init = __bind(this.init, this);
}
App.prototype.init = function() {
this.view = new ApplicationView();
};
return App;
})();
});
最后是我的 applicationView.js
define(['underscore', 'backbone', 'views/AbstractView', 'App'], function(_, Backbone, AbstractView, App) {
'use strict';
var RegisterView;
return RegisterView = (function(_super) {
__extends(RegisterView, _super);
function RegisterView() {
this.init = __bind(this.init, this);
return RegisterView.__super__.constructor.apply(this, arguments);
}
RegisterView.prototype.init = function() {
RegisterView.__super__.init.apply(this, arguments);
this.model = App.user; // APP IS UNDEFINED
};
})(AbstractView);
});
【问题讨论】:
标签: javascript backbone.js coffeescript requirejs