1
我正在嘗試使用骨幹,牽線木偶和咖啡標記製作多頁面應用程序。Backbone,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返回的對象,無法正常工作。