在下面的應用程序中,我試圖將id
的動態添加到生成的項目中。我的代碼工作正常,但是當我在其中添加下面的兩條評論線。它拋出錯誤Uncaught Ext.AbstractManager.register():註冊重複的ID
未捕獲Ext.AbstractManager.register():註冊副本ID「73」這個經理
當我試圖找出錯誤的根源,我發現,代碼工作正常,直到執行81
id(console.log(_idGen)
)。由此可見,該錯誤與超出範圍的異常有關。 (9 * 9 = 81)也只在小提琴,當我添加HTML文本到子面板,我才知道,他們之間的73 to 81
??(而不是1 to 81
)這是困惑我,如何?
Ext.onReady(function(){
var _idGen = 1;
var childItems = [], items = [];
for (var i = 0; i < 9; i++) {
childItems.length = 0;
for (var j = 0; j < 9; j++) {
childItems.push({
xtype: 'panel',
/****************************/
id: _idGen,
html: _idGen + "",
/****************************/
width: 50,
height: 50,
style: {borderWidth: '1px'}
});
console.log(_idGen);
/*****************************/
_idGen++;
/*****************************/
}
items.push({
xtype: 'panel',
layout: {
type: 'table',
columns: 3
},
items: childItems
});
}
Ext.create('Ext.container.Container', {
layout: {
type: 'table',
// The total column count must be specified here
columns: 3
},
renderTo: Ext.getBody(),
style: {width: '455px',marginLeft: 'auto',marginRight: 'auto', marginTop: '30px'},
items: items
});
});
能否請你來這裏http://chat.stackoverflow.com/房間/ 23760 /煎茶..如果你有時間:)(其他人也歡迎) –
@Mr_Green我已經編輯了代碼並與評論內聯。簡而言之:你需要保存相同的數組,你需要9個獨特的數組 – sra
yes thankyou :) ..這個Id的後綴是'body' –