obj.如果在ExtJs类原型中定义了构造函数,则get函数失败
obj.get function fails if constructor is defined in ExtJs Class prototype
我是ExtJs世界的新手,从ExtJs 4开始,使用《学习ExtJs 4》这本书
下面是我正在使用
的代码片段Ext.define("MyApp.Category",{
height : 40,
extend : "Ext.data.Model",
fields : [
"id",
"name",
"description"
],
constructor : function(config){
console.log("Config Dump 'n");
console.dir(this);
//Ext.apply(this, config);
}
});
var category = Ext.create("MyApp.Category",{
id : 1,
name : "Entertainment",
description : "Expenses to have some fun"
});
console.log("this is after instantiation..");
console.debug(category);
console.log(category.get("name"));
// above line fails gives error - Uncaught TypeError: Cannot read property 'name' of undefined
// but if we remove construction defination from class prototype , .get function works very well
console.log(category.get("description"));
你能帮我弄明白这是怎么回事吗
必须调用父构造函数。将this.callParent(arguments)
添加到构造函数覆盖中
相关文章:
- ES6构造函数返回基类的实例
- 使用Google Visualization动态调用构造函数
- javascript中对象构造函数中的var属性与this.properties
- 理解typescript中的构造函数接口
- 为什么构造函数不是构造函数
- 如果在构造函数中有“返回”,则在 JavaScript 中的新运算符中做了什么
- 拦截对构造函数的调用
- 使用闭包共享构造函数参数
- 文本表示法VS.构造函数,用于在JavaScript中创建对象
- 从js引擎的角度来看闭包和构造函数是如何工作的
- 如何使用此从对象访问构造函数
- Javascript:为什么是构造函数's __proto__属性Empty(){}
- 当一个重要的构造函数参数丢失时应该发生什么
- Chrome Javascript日期构造函数错误
- 如何使用构造函数's的输出,以便将值插入到对象中
- JS在构造函数中使用get
- 在工厂构造函数中解析 Restangular.get
- 在构造函数函数中创建只读(get)属性
- 将get和set添加到构造函数的原型链中
- obj.如果在ExtJs类原型中定义了构造函数,则get函数失败