Backbone.js 主干,xxx不是构造函数?
我正在尝试使用主干网、木偶和咖啡脚本制作多页应用程序 apps/home.coffeeBackbone.js 主干,xxx不是构造函数?,backbone.js,requirejs,Backbone.js,Requirejs,我正在尝试使用主干网、木偶和咖啡脚本制作多页应用程序 apps/home.coffee define [ 'App' './index/index' ], (App, HomeIndex) -> class HomeApp extends App constructor : () -> super console.log typeof HomeIndex #return object
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
apps/home/index/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返回对象的类型,而不是函数。首先,当您遇到这样的问题时,请检查Requirejs加载的文件。您可能已经看到
/index/index
不是您所期望的,或者根本没有加载
基本上,AMD不支持相对链接。仅与baseUrl
相关的链接
define [
'App'
'apps/home/index/index'
],