我已經在sencha中編寫了一個程序,該程序運行良好。由於我的文件變得太大,我正在嘗試使用xtypes將它們分成多個小文件。未捕獲嘗試使用尚未註冊的xtype創建組件:
基本上,我想有一個main.js文件調用一個的xtype list.js呼叫其他的xtype details.js還呼籲需要xtypes ...
我的問題是,既然我已經開始分裂我的代碼,我得到這個錯誤:Uncaught Attempting to create a component with an xtype that has not been registered
。
我確定每個文件都正確鏈接到我的index.html中。
這裏是我的代碼示例:
Details.js
var details = Ext.extend(Ext.Panel, {
layout: 'card',
cardSwitchAnimation: 'slide',
initComponent: function(){
Ext.apply(this,{
items:[]
})
details.superclass.initComponent.apply(this,arguments);
}
});
Ext.reg('details', details);
List.js
var Details = {xtype: 'details'};
var ListWrapper = new Ext.Panel({
id: "listwrapper",
layout: 'fit',
items: [List],
dockedItems: [homeTitleBar]
});
var Home = new Ext.Panel({
id: "home",
layout: 'card',
cardSwitchAnimation: 'slide',
items: [ListWrapper, Details]
});
var HomeTab = Ext.extend(Ext.Panel, {
iconCls: 'home',
title: 'Home',
layout: 'card',
initComponent: function() {
Ext.apply(this,{
items: [Home]
});
HomeTab.superclass.initComponent.apply(this,arguments);
}
});
Ext.reg('home', HomeTab);
Main.js
var menuBar = Ext.extend(Ext.TabPanel, {
layout: 'card',
cardSwitchAnimation: 'slide',
fullscreen: true,
tabBar: {
dock: 'bottom',
layout: {pack: 'center'}
},
items:[
{xtype: 'home'}
]
});
Ext.reg("menuBar", menuBar);