我已經開始使用2.2版本的新主幹,牽線木偶並需要使用項目(我以前曾使用1.8版本)看起來好像有很多變化。當瀏覽器加載的提線木偶,我得到一個錯誤:Marionette v2.2升級錯誤 - 無法讀取未定義的屬性'ChildViewContainer'
Uncaught TypeError: Cannot read property 'ChildViewContainer' of undefined
這是我main.js文件:
require.config({
baseURL: 'scripts',
paths: {
"jquery": "lib/jquery",
"underscore": "lib/underscore",
"backbone": "lib/backbone",
"marionette": 'lib/backbone.marionette',
"templates": "../templates",
"text": "lib/text"
},
shim: {
underscore: {
exports: '_'
},
backbone: {
deps: ['underscore', 'jquery'],
exports: 'Backbone'
},
marionette: {
deps: ['jquery', 'underscore', 'backbone'],
exports: 'Marionette'
},
waitSeconds: 15
}
});
require([ "app", "marionette"], function(App, marionette) {
App.start();
});
這是我的app.js文件:
define(["marionette", "router"], function (Marionette, AppRouter) {
var MyApp = Marionette.Application.extend({
initialize: function(options) {
console.log("options.container");
}
});
var MyApp = new MyApp({container: '#page'});
MyApp.addInitializer(function (options) {
MyApp.Router = new AppRouter();
Backbone.history.start();
});
// export the app from this module
return MyApp;
});
確定此錯誤的原因不在您提供的代碼段中。 childViewContainer - 是CompositeView的一個屬性,我沒有看到任何發生在路由器之外的事情嗎? – Evgeniy 2014-10-13 09:56:16
好吧,當添加斷點時,錯誤發生在創建路由器或甚至運行路由器腳本之前:/它基本上拋出錯誤,因爲它加載Marrionette文件,這就是爲什麼我認爲它必須是我在主或應用文件。我無法找到任何有用的木偶v2樣板來交叉引用,甚至只是用來開始。 – 2014-10-13 14:32:57
你在哪裏使用'{container:'#page'}'選項傳遞給應用程序初始化?我看不到任何地區。我在Marionette的文檔中看到了相同的內容,但這不是您應該使用它的方式。您應該添加初始化工具,它將使用該選項將新區域附加到'#page''。 – 2014-10-13 18:33:14