2014-10-12 25 views
-1

我已經開始使用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; 
}); 
+0

確定此錯誤的原因不在您提供的代碼段中。 childViewContainer - 是CompositeView的一個屬性,我沒有看到任何發生在路由器之外的事情嗎? – Evgeniy 2014-10-13 09:56:16

+0

好吧,當添加斷點時,錯誤發生在創建路由器或甚至運行路由器腳本之前:/它基本上拋出錯誤,因爲它加載Marrionette文件,這就是爲什麼我認爲它必須是我在主或應用文件。我無法找到任何有用的木偶v2樣板來交叉引用,甚至只是用來開始。 – 2014-10-13 14:32:57

+1

你在哪裏使用'{container:'#page'}'選項傳遞給應用程序初始化?我看不到任何地區。我在Marionette的文檔中看到了相同的內容,但這不是您應該使用它的方式。您應該添加初始化工具,它將使用該選項將新區域附加到'#page''。 – 2014-10-13 18:33:14

回答

-1

只要看看你的backbone.js文件。它是空的。從http://backbonejs.org/下載backbone.js並將其替換。

+0

雖然我的backbone.js文件不是空的。它是從官方網站 – 2014-10-23 12:32:30

+1

下載的,請提供您的任何'Marionette.CompositeView'代碼。變化是從項目到孩子 – Muhaimin 2014-10-23 14:06:55

-1

我剛剛遇到了同樣的問題。問題在於頁面上包含了多個Marionette實例。 (我錯誤地在cdnjs的頁面上放置了木偶的腳本標籤,並試圖通過require在本地包含靜態文件)。刪除對外部JS文件的引用幫助我...

相關問題