您需要定义它。你可以给它一个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'? –