我正在迁移
ext js 4 to ext js 5.1
。我的extjs 4.2.1中有代码,升级到extjs 5.1后出现控制台错误。它在ExtJs 4.2.1中运行良好,不知道为什么会出现错误,说
未捕获错误:[Ext.create]无法识别的类名/别名:MyApp.store.LibraryFolderTreeStore
Ext.define('MyApp.view.library.LibraryTreeView', {
extend : 'Ext.tree.Panel',
alias : 'widget.librarytreeview',
requires: [
'MyApp.store.LibraryFolderTreeStore'
],
store : Ext.create("MyApp.store.LibraryFolderTreeStore") // getting error on this line
....
});
定义类时不能使用
Ext.Create
。
您必须使用
initComponent
方法,您可以使用 Ext.Create
分配配置。
Ext.define('MyApp.view.library.LibraryTreeView', {
extend : 'Ext.tree.Panel',
alias : 'widget.librarytreeview',
requires: [
'MyApp.store.LibraryFolderTreeStore'
],
initComponent : function(){
this.store = Ext.create("MyApp.store.LibraryFolderTreeStore");
this.callParent();
}
// getting error on this line
....
});