Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/395.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript Ext js重写初始化组件函数_Javascript_Html_Extjs_Overriding - Fatal编程技术网

Javascript Ext js重写初始化组件函数

Javascript Ext js重写初始化组件函数,javascript,html,extjs,overriding,Javascript,Html,Extjs,Overriding,我试图重写Ext.window.MessageBox类的initComponent函数中的一些代码。但我改变的东西都没有得到应用 这里有什么问题?我错过什么了吗 Ext.define('hds.override.MessageBox', { override: 'Ext.window.MessageBox', initComponent: function() { console.log("init component 1"); //not reached t

我试图重写Ext.window.MessageBox类的initComponent函数中的一些代码。但我改变的东西都没有得到应用

这里有什么问题?我错过什么了吗

Ext.define('hds.override.MessageBox', {
    override: 'Ext.window.MessageBox',

   initComponent: function() {

    console.log("init component 1"); //not reached

    this.callParent();


    console.log("init component 2"); //not reached
  }


});
编辑:


我还尝试用extend替换override,但仍然没有到达内部组件。更改为extend时是否需要更改文件的位置???

如果要更改Ext.Msg的行为,它是类Ext.window.MessageBox的实例,则需要将其作为重写类的实例:

Ext.define('MyMessageBox', {
    override: 'Ext.window.MessageBox',
    initComponent: function() {
        this.callParent();
        //your changes here..
    }
},function() {
    Ext.MessageBox = Ext.Msg = new this();
});

查看这里,我在initComponent中更改了默认填充

,如果要更改Ext.Msg的行为,它是类Ext.window.MessageBox的实例,则需要将其作为重写类的实例:

Ext.define('MyMessageBox', {
    override: 'Ext.window.MessageBox',
    initComponent: function() {
        this.callParent();
        //your changes here..
    }
},function() {
    Ext.MessageBox = Ext.Msg = new this();
});

查看这里,我在initComponent中更改了默认填充

是否在函数中调用this.callParent?您确定需要覆盖Ext.MessageBox而不是Ext.window.MessageBox吗?我已尝试使用callParent,但没有帮助。您是否尝试覆盖Ext.window.MessageBox?是的,没有更改。但是我更新了我的代码,因为我认为这是另一个错误。我测试了一些东西,导致Ext.MessageBox是一个单例,它在到达代码之前被实例化,所以需要扩展它。你在函数中调用this.callParent吗?您确定需要覆盖Ext.MessageBox而不是Ext.window.MessageBox吗?我已尝试使用callParent,但没有帮助。您是否尝试覆盖Ext.window.MessageBox?是的,没有更改。但是我更新了我的代码,因为我认为这是另一个错误。我测试了一些东西,因为Ext.MessageBox是一个单例,它在到达代码之前被实例化,所以您需要完美地扩展它!非常感谢!完美的非常感谢!