我正在使用 extjs 5,我正在尝试使用 Ajax 创建几个树面板来检索 JSON 并在应用程序主体上填充面板。
当我加载页面时,它会引发错误并且不会填充 Ext.panel.Panel。
Firebug shows:
TypeError: Ext.PluginManager is undefined bootstr... > eval (línea 5276, columna 16)
Chrome console:
Uncaught TypeError: Cannot read property 'create' of undefined Component.js:5276
Ext.define.privates.constructPlugin Component.js:5276
Ext.define.privates.constructPlugins Component.js:5305
Ext.define.initComponent Component.js:3156
Ext.Base.Base.addMembers.callParent Base.js:1256
Ext.define.initComponent Component.js:5
Ext.Base.Base.addMembers.callParent Base.js:1256
Ext.define.initComponent Container.js:1248
Ext.Base.Base.addMembers.callParent Base.js:1256
Ext.define.initComponent Container.js:269
Ext.define.constructor Component.js:1718
constructor Class.js:29
Ext.define.initComponent Table.js:489
Ext.Base.Base.addMembers.callParent Base.js:1256
Ext.define.initComponent Table.js:11
Ext.Base.Base.addMembers.callParent Base.js:1256
Ext.define.initComponent Panel.js:400
Ext.define.constructor Component.js:1718
Ext.Base.Base.addMembers.callParent Base.js:1256
Ext.define.constructor Table.js:383
Ext.Base.Base.addMembers.callParent Base.js:1256
Ext.define.constructor Panel.js:323
constructor Class.js:29
(anonymous function) VM1904:3
Ext.ClassManager.Ext.apply.create ClassManager.js:1413
(anonymous function) Main.js:56
Ext.Array.ExtArray.each Array.js:345
Ext.Ajax.request.success Main.js:49
Ext.apply.callback Util.js:108
Ext.define.onComplete Connection.js:1112
Ext.define.onStateChange Connection.js:1048
(anonymous function) Function.js:164
我的代码:
主.js
Ext.require([
'Ext.tree.*',
'Ext.grid.*',
'Ext.ux.*',
'Ext.panel.*',
'Ext.container.*'
]);
var carpetasPanel = Ext.create('Ext.panel.Panel',{
title: 'SIE - Menú',
width: 250,
region: 'west',
id: 'accordionPanel',
layout: {
type: 'accordion',
align: 'stretch',
titleCollapse: false,
animate: true
},
collapsible: true,
defaultType: 'treepanel',
split: true,
defaults: {
rootVisible: false,
flex: 1,
useArrows: true
}
});
Ext.Ajax.request({
url: 'resources/carpetas.json',
success: function(response){
var nodes = Ext.JSON.decode(response.responseText);
Ext.each(nodes, function(node) {
carpetasPanel.add({
title: node.id,
text: node.text,
id: node.id,
items: Ext.create('Ext.tree.Panel', {
header: false,
width: 250,
height: 600,
rootVisible: false,
root: {
expanded: false,
children: node.children
}
})
});
});
}
});
Ext.define('SIEE.view.main.Main', {
extend: 'Ext.container.Container',
xtype: 'app-main',
controller: 'main',
viewModel: {
type: 'main'
},
layout: {
type: 'border'
},
items: [ carpetasPanel]
});