未捕获的TypeError EmberJS初始值设定项
Uncaught TypeError EmberJS initializer
所以我一直在学习EmberJS中的身份验证教程,当我添加该页面上显示的初始值设定项时,它会破坏我的应用程序。
这是破坏应用程序的代码
Ember.Application.initializer({
name: 'currentUser',
initialize: function(container) {
var store = container.lookup('store:main');
var user = App.User.find('current');
container.lookup('controller:currentUser').set('content', user);
container.typeInjection('controller', 'currentUser', 'controller:currentUser');
}
});
这就是发生的错误
Uncaught TypeError: Object function () {
if (!wasApplied) {
Class.proto(); // prepare prototype...
}
o_defineProperty(this, GUID_KEY, undefinedDescriptor);
o_defineProperty(this, '_super', undefinedDescriptor);
var m = meta(this), proto = m.proto;
m.proto = this;
if (initMixins) {
// capture locally so we can clear the closed over variable
var mixins = initMixins;
initMixins = null;
this.reopen.apply(this, mixins);
}
if (initProperties) {
// capture locally so we can clear the closed over variable
var props = initProperties;
initProperties = null;
var concatenatedProperties = this.concatenatedProperties;
for (var i = 0, l = props.length; i < l; i++) {
var properties = props[i];
Ember.assert("Ember.Object.create no longer supports mixing in other definitions, use createWithMixins instead.", !(properties instanceof Ember.Mixin));
for (var keyName in properties) {
if (!properties.hasOwnProperty(keyName)) { continue; }
var value = properties[keyName],
IS_BINDING = Ember.IS_BINDING;
if (IS_BINDING.test(keyName)) {
var bindings = m.bindings;
if (!bindings) {
bindings = m.bindings = {};
} else if (!m.hasOwnProperty('bindings')) {
bindings = m.bindings = o_create(m.bindings);
}
bindings[keyName] = value;
}
var desc = m.descs[keyName];
Ember.assert("Ember.Object.create no longer supports defining computed properties.", !(value instanceof Ember.ComputedProperty));
Ember.assert("Ember.Object.create no longer supports defining methods that call _super.", !(typeof value === 'function' && value.toString().indexOf('._super') !== -1));
Ember.assert("`actions` must be provided at extend time, not at create time, when Ember.ActionHandler is used (i.e. views, controllers & routes).", !((keyName === 'actions') && Ember.ActionHandler.detect(this)));
if (concatenatedProperties && indexOf(concatenatedProperties, keyName) >= 0) {
var baseValue = this[keyName];
if (baseValue) {
if ('function' === typeof baseValue.concat) {
value = baseValue.concat(value);
} else {
value = Ember.makeArray(baseValue).concat(value);
}
} else {
value = Ember.makeArray(value);
}
}
if (desc) {
desc.set(this, keyName, value);
} else {
if (typeof this.setUnknownProperty === 'function' && !(keyName in this)) {
this.setUnknownProperty(keyName, value);
} else if (MANDATORY_SETTER) {
Ember.defineProperty(this, keyName, null, value); // setup mandatory setter
} else {
this[keyName] = value;
}
}
}
}
}
finishPartial(this, m);
this.init.apply(this, arguments);
m.proto = proto;
finishChains(this);
sendEvent(this, "init");
} has no method 'find'
在ember数据1.0.0-beta中,DS.Model
子类(如App.User
)没有find
方法。相反,你必须使用:
store.find('user');
查找所有数据- 按id查找
store.find('user', id);
store.find('user', { key: name });
通过查询查找
结果如下:
Ember.Application.initializer({
name: 'currentUser',
initialize: function(container) {
var store = container.lookup('store:main');
var user = store.find('user','current');
container.lookup('controller:currentUser').set('content', user);
container.typeInjection('controller', 'currentUser', 'controller:currentUser');
}
});
我希望它能帮助
相关文章:
- Emberjs应用程序加载在除Index之外的所有路由上
- TypeError:无法读取属性'推'未定义的JavaScript
- 未捕获的TypeError无法读取未定义的属性socialsharing
- 扩展SVGTextElement时出现Typescript Uncaught TypeError
- TypeError:在不兼容的接收器nodejs上调用了方法Uint8Array.length
- TypeError:_this.store.getState在使用来自Redux的连接时不是函数
- EmberJS中支持单字母单词模型
- gulp Iconify任务抛出错误TypeError:Path必须是字符串.收到false
- Uncaught TypeError:undefined不是函数-ember js
- 得到"TypeError:无法读取属性'filename'未定义的“;调用“npm start
- 试图将onChange函数作为道具传递给GrandChlidren,结果是TypeError:这是未定义的
- Snap()方法导致Uncaught TypeError
- Mongoose TypeError:实例化模式类型的对象时,对象不是函数
- jQuery使用ajax自动完成问题-TypeError:this.source不是函数
- 角度推入数组给出:TypeError:无法读取属性'推'的未定义
- Emberjs返回TypeError:stateManager未定义
- 未捕获的TypeError EmberJS初始值设定项
- TypeError: newHandlerInfo在emberjs中未定义
- EmberJS:加载路由时出错:TypeError:无法读取属性'地图'为null
- Emberjs Uncatch TypeError:Object #