您需要定義它。你可以給它一個xtype別名來輕鬆地引用它。確保在嘗試調用它之前加載它(通過使用'require')。
Ext.define('My.namespace.Component', {
extend: 'Ext.container.Container', //extend Container
alias: 'widget.mycomponent', //this is the xtype (minus 'widget.')
layout:{
type:'hbox'
},
initComponent:function(){
Ext.applyIf(this, {
items: [
{
xtype: 'textfield',
fieldLabel: 'Label',
flex: 1
},
{
xtype: 'button',
text: 'MyButton',
flex: 1
}
]
});
this.callParent(arguments); //everything breaks if you forget this
}
});
在視圖中或其它部件
,使用需要來加載上述組分:
...
requires:[
'My.namespace.Component'
]
...
使用方法如下:
{
xtype:'mycomponent',
width:666
}
你是什麼意思」cus湯姆控制「?你想把這個容器定義爲單獨的組件,即。 'Ext.container.Container'? –