Model view controller Ember视图并使用值初始化-TypeError:this.currentState未定义

Model view controller Ember视图并使用值初始化-TypeError:this.currentState未定义,model-view-controller,ember.js,frontend,Model View Controller,Ember.js,Frontend,在呈现模板之前,我无法使用余烬视图并使用值初始化它们。使用下面的代码,我在浏览器中遇到以下错误: 类型错误:此.currentState未定义 this.currentState.childViewsDidChange(this,views,start,added) 我的问题是,错误消息意味着什么,是否有其他方法可以更好地工作 App.SmileyFaceView = Ember.ContainerView.extend childViews: null init: () ->

在呈现模板之前,我无法使用余烬视图并使用值初始化它们。使用下面的代码,我在浏览器中遇到以下错误:

类型错误:此.currentState未定义 this.currentState.childViewsDidChange(this,views,start,added)

我的问题是,错误消息意味着什么,是否有其他方法可以更好地工作

App.SmileyFaceView = Ember.ContainerView.extend
  childViews: null

  init: () ->
    @_super

    happy = App.SmileyFace.create()
    happy.setFace(":)")

    angry = App.AngryFace.create()
    angry.setFace(">:(")

    blah = App.BlahFace.create()
    blah.setFace(":|")

    @pushObject(happy)
    @pushObject(angry)
    @pushObject(blah)

App.SmileyFaceView = Ember.View.extend
  tagName: "span"
  template: null

  setFace: (face) ->
    @set('template', Ember.Handlebars.compile(face))

您可能希望为不同的视图指定不同的名称。(另外,先定义childview。不知道是否需要它,只是更合理而已……)您是否尝试过在ContainerView
didinsertElement
而不是
init
方法中设置您的childview?