繁体   English   中英

Content属性在新的Brunch-Ember应用程序中未定义

[英]Content property is undefined in new Brunch-Ember application

我正在使用Brunch框架启动新的Ember应用程序: Brunch with Ember 我创建了一个简单的ApplicationController并将content属性设置为一个空对象:

var App = require('app');

App.ApplicationController = Em.ObjectController.extend({
    content: { }
});

但是,当我在浏览器中加载应用程序时,App.ApplicationController.content的content属性未定义。 同样,set和pushObject函数也未在App.ApplicationController上定义。 有什么想法我想念的吗?

您仅在此处定义了Controller类。 您需要创建Class的实例

通常,您可以使用以下方法进行操作:

App.initialize();

在这种情况下,Ember将为您实例化控制器。 您将在路径App.router.applicationController中找到您的控制器。

但是您也可以手动实例化Controller,例如:

App.yourController = App.ApplicationController.create();

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM