这看起来像正确的语法 - 可能检查您的ID以确保您获得对组件的引用?此拨弄用5,但我4测试,以及:
https://fiddle.sencha.com/fiddle/ba6/
Ext.application({
name : 'Fiddle',
launch : function() {
var panel = Ext.create('Ext.Panel',{
renderTo:Ext.getBody(),
title:'myPanel',
items: [
Ext.create('Ext.panel.Panel', {
layout: 'card',
id: 'PanelID',
activeItem: 0,
items: [Ext.create('Ext.panel.Panel', {
itemId: 'card-1',
html: 'hello'
}),
Ext.create('Ext.panel.Panel', {
itemId: 'card-2',
html: 'hello2'
})]
}),
Ext.create('Ext.Button', {
text: 'change item in layout',
handler: function() {
Ext.getCmp('PanelID').layout.setActiveItem('card-2');
}
})
]
});
}
});