我正在尝试使用骨干,木偶和coffeescript制作多页应用。
应用/ 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'
],
但仍然是HomeIndex返回对象的类型,而不是函数。
答案 0 :(得分:0)
首先,遇到这样的问题时,请检查Requirejs加载的文件。您可能已经看到./index/index
要么不是您所期望的,要么根本没有加载。
基本上,AMD不支持相关链接。仅链接相对于baseUrl
。