2013-10-15 3 views
1

백본, 마리오 네트 및 coffeescript를 사용하여 다중 페이징 된 앱을 만들려고합니다.백본, xxx는 생성자가 아닙니다?

애플 리케이션/home.coffee

define [ 
    'App' 
    './index/index' 
], 
(App, HomeIndex) -> 
    class HomeApp extends App 
     constructor :() -> 
      super 
      console.log typeof HomeIndex #return object 
      @homeIndex = new HomeIndex() #TypeError: HomeIndex is not a constructor 
      @initialize() 

     initialize: -> 
      console.log 'app initialize' 
      App.contentArea.show homeIndex 

애플 리케이션/홈/색인/index.coffee

define [], 
()-> 
    class HomeIndex extends Backbone.Marionette.Layout 
     template: '<div>Hello, Backbone! </div>' 

     constructor:() -> 
      console.log '!' 

     initialize: (options) -> 
      @template = _.template @template 
      console.log "Home Index initialized" 

     render:() => 
      @$el.html @template 

내가 HomeIndex가, 누군가가 내가 뭘 잘못 알고 초기화 할 수 없습니다?

define [ 
     'App' 
     'apps/home/index/index' 
    ], 

을 여전히 대해서 typeof HomeIndex 반환 객체는 작동하지 :

업데이트 조언을 바랍니다.

답변

0

우선이 문제가 발생하면 Requirejs가로드 한 파일을 확인하십시오. ./index/index이 예상 한 것과 다르거 나 전혀로드되지 않은 것을 보았을 것입니다.

기본적으로 AMD는 상대 링크를 지원하지 않습니다. baseUrl과 관련된 링크 만

관련 문제