extjs如何将参数传递给组件配置 [英] extjs how to pass parameters to the component config
本文介绍了extjs如何将参数传递给组件配置的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有此代码:
Ext.define('...', {
extend: 'Ext.container.Container',
...
config: {
mydata: [],
myname: '',
myid: null
},
items: [
...
{
xtype: 'button',
text: 'Go',
tooltip: 'Click here',
listeners: {
click: function (item, e, eOpts) {
var config = item.up('container').config;
console.log('Data', config.mydata, ' Name', config.myname, ' Id', config.myid);
}
}
}
],
constructor: function () {
this.callParent(arguments);
},
initComponent: function () {
this.initConfig({
mydata: ['Data1','Data2'],
myname: 'Hello',
myid: 10
});
}
});
当单击按钮时,它会响应Data [] Name '' Id null
,配置默认定义中的数据完全相同...我该如何正确设置此初始配置?
when clicking the button it responses Data [] Name '' Id null
, the very same data in config default definition... how can I set this initial config the correct way?
推荐答案
您可以在initComponent中应用所需的参数:
You can apply the needed params in initComponent:
initComponent: function () {
Ext.apply(this, {
config: {
mydata: ['Data1','Data2'],
myname: 'Hello',
myid: 10
}
});
this.callParent(arguments);
}
这篇关于extjs如何将参数传递给组件配置的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文