0dd*_*b1t 4 javascript arguments extjs
我有一些课
AddOrgWindowUI = Ext.extend(Ext.Window, {
title: 'form',
width: 400,
height: 198,
layout: 'form',
padding: 5,
initComponent: function() {
this.items = [
{
xtype: 'textfield',
fieldLabel: 'parapapa',
anchor: '95%',
value: m,
emptyText: 'perapapa'
}
];
AddOrgWindowUI.superclass.initComponent.call(this);
}});
Run Code Online (Sandbox Code Playgroud)
当我创建一个对象时,var AddOrgWindowForm = new AddOrgWindowUI('aaa');我希望将arg('aaa')转换为我的新表单值(值m).怎么弄明白?我正在努力initComponent: function(m) {,那不行.
该initComponent函数在其中一个基类上内部调用Ext.Window.你不应该试着直接调用它.这就是为什么它不会处理你自己的参数.
因此,我建议您在扩展ExtJS类时使用标准表单参数.
它就像使用要覆盖的属性初始化对象一样简单(或者在属性不存在的情况下插入).然后只需使用this关键字来访问它们.
这是可能的,因为对于每个Ext.Component及其子类,传递给构造函数的第一个参数应该是一个对象,并且该对象中的每个成员都将被复制到构造的新对象中.大多数ExtJS类都直接或间接地扩展Ext.Component,并且您也从中Ext.Window扩展Ext.Component.
在这里你修复了你的例子:
var AddOrgWindowUI = Ext.extend(Ext.Window, {
title: 'form',
width: 400,
height: 198,
layout: 'form',
padding: 5,
initComponent: function() {
this.items = [
{
xtype: 'textfield',
fieldLabel: 'parapapa',
anchor: '95%',
value: this.initialValue,
emptyText: 'perapapa'
}
];
AddOrgWindowUI.superclass.initComponent.call(this);
}
});
function test() {
var AddOrgWindowForm = new AddOrgWindowUI({initialValue:'aaa'});
AddOrgWindowForm.show();
}
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
6542 次 |
| 最近记录: |