0
使用Backbone.Marionette創建新應用程序時,當我運行Express應用程序並加載頁面時我在控制檯中得到一個錯誤:未捕獲TypeError:無法讀取未定義屬性EventAggregator
Uncaught TypeError: Cannot read property 'EventAggregator' of undefined
backbone.marionette.js:1504
顯示它在實際的marionette
庫中。我一直在看這條線:
Marionette.EventAggregator = Backbone.Wreqr.EventAggregator;
,並在想,wreqr
可能是一個額外的庫我要補充的嗎?
下面是一個創建應用程序的代碼:
require([
'jquery',
'underscore',
'backbone',
'marionette'
], function($, _, Backbone, Marionette){
MyApp = new Backbone.Marionette.Application();
MyApp.addRegions({
main_region: '#main_region'
});
MyApp.addInitializer(function(options) {
var login_form_view = new LoginFormView();
});
});
和要求的配置,設置了圖書館地點:
// using RequireJS 1.0.7
require.config({
paths: {
'$': 'libs/jquery-1.8.2-min',
'underscore': 'libs/underscore-min', // AMD support
'backbone': 'libs/backbone.min', // AMD support
'bootstrap' : 'libs/bootstrap.min',
'marionette' : 'libs/backbone.marionette',
'wreqr' : 'libs/backbone.wreqr',
'templates': '../templates',
'text': 'libs/require/text',
'login': 'views/user/login'
}
});
任何人都知道這可能是造成這個錯誤嗎?
謝謝,我會給你一個鏡頭並報告回來。 1秒。 – Matt
成功!還必須添加EventBinder:https://github.com/marionettejs/backbone.eventbinder – Matt
僅供參考:與v1.0.0-beta2,我做了這樣的「backbone.marionette.js」文件中包含Wreqr和EventBinder。不過,如果你願意,你可以下載沒有依賴關係的「core」marionette.js文件。 HTTP://marionettejs.com#downloads –