ExtJS的4类加载失败
问题描述:
我有类似下面的代码:ExtJS的4类加载失败
Ext.define('GG.view.Workbench', {
extend: 'Ext.container.Viewport',
layout: 'fit',
items: [
{
xtype: 'container',
layout: 'border',
items: [
{
region: 'center',
items: [
Ext.create('GG.view.Foo')
]
},
{
region: 'south',
items: [
Ext.create('GG.view.Bar')
]
}
]
}
],
initComponent: function() {
this.callParent(arguments);
}
});
什么情况是,当两个Ext.create
调用放在那里的代码无法正常工作。
这是我得到的Chrome:
Uncaught TypeError: object is not a function
(anonymous function)
Ext.ClassManager.instantiateext-debug.js:6428
(anonymous function)ext-debug.js:2414
(anonymous function)
我怎么使用这个Ext.create
?
答
你overnesting,你必须要做到这一点,将在每次创建类时执行的方法中
Ext.define('GG.view.Workbench', {
extend: 'Ext.container.Viewport',
layout: 'border',
initComponent: function() {
var me = this;
Ext.apply(me, {
items : me.buildItems()
});
me.callParent(arguments);
},
buildItems: function() {
return [
{
region: 'center',
items: [
Ext.create('GG.view.Foo')
]
},
{
region: 'south',
items: [
Ext.create('GG.view.Bar')
]
}
];
}
});