我有一个像
这样的小组 var filterPanel = Ext.create('Ext.panel.Panel', {
bodyPadding: 5,
width: 300,
myValue:5,
title: 'Filters',
initComponent: function() {
this.items = [{
xtype: 'textfield',
value: this.myValue
}];
this.callParent();
}
renderTo: Ext.getBody()
});
我尝试创建一个项目xtype: 'textfield'
且值为myValue
的面板。但那是失败的。
如何做到这一点谢谢。 以下是我的示例文字 http://jsfiddle.net/4Cmuk/
答案 0 :(得分:4)
您正在使用Ext.create()
函数,该函数用于创建类的实例。使用initComponent
函数定义类时可以使用Ext.define()
方法,我不确定initComponent
函数不能使用Ext.create()
方法。
例如看下面的代码,它将得到执行:
Ext.define('customPanel', {
extend: 'Ext.panel.Panel',
bodyPadding: 5,
width: 300,
myValue:5,
title: 'Filters',
initComponent: function() {
this.items = [{
xtype: 'textfield',
value: this.myValue
}];
this.callParent(arguments);
},
renderTo: Ext.getBody()
});
Ext.create('customPanel');