iteye_6151 2010-10-19 14:58
浏览 187
已采纳

extjs定义一个类,在类中加入成员变量出现错误

RegisterWindow=Ext.extend(Ext.Window,{
formPanel:new RegisterFormPanel(),
constructor:function(_config){
_config=Ext.apply({
title:"注册窗口",
width:400,
items:[this.formPanel]
},_config);
RegisterWindow.superclass.constructor.call(this,_config);
}
});
/************************************************************************************/
RegisterFormPanel=Ext.extend(Ext.form.FormPanel,{
constructor:function(_config){
_config=Ext.apply({
labelWidth:75,
defaults:{
xtype:"textfield",
anchor:"98%"
},
items:[{
fieldLabel:"姓名"
}],
buttons:[{
text:"注册"
},{
text:"重置"
}]
},_config);
RegisterFormPanel.superclass.constructor.call(this,_config);
}
});
上面的代码包含在文件中 调用var _registerWindow = new RegisterWindow().show();出现RegisterWindow未定义怎么回事

  • 写回答

1条回答 默认 最新

  • lizhiyezi 2010-10-19 15:01
    关注

    js 是顺序执行的。在执行 RegisterWindow=Ext.extend(Ext.Window,{
    formPanel:new RegisterFormPanel(), 的时候RegisterFormPanel还没声明

    吧他们顺序替换下就行了。

    /************************************************************************************/
    RegisterFormPanel=Ext.extend(Ext.form.FormPanel,{
    constructor:function(_config){
    _config=Ext.apply({
    labelWidth:75,
    defaults:{
    xtype:"textfield",
    anchor:"98%"
    },
    items:[{
    fieldLabel:"姓名"
    }],
    buttons:[{
    text:"注册"
    },{
    text:"重置"
    }]
    },_config);
    RegisterFormPanel.superclass.constructor.call(this,_config);
    }
    });
    RegisterWindow=Ext.extend(Ext.Window,{
    formPanel:new RegisterFormPanel(),
    constructor:function(_config){
    _config=Ext.apply({
    title:"注册窗口",
    width:400,
    items:[this.formPanel]
    },_config);
    RegisterWindow.superclass.constructor.call(this,_config);
    }
    });

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?