Difference between Class.override() vs Ext.define('Class', override: 'Class' … to create an override [duplicate]

筅森魡賤 提交于 2019-12-10 12:19:47

问题


What's the difference between these 2 override

So option 1:

Ext.window.Window.override({
    initComponent: function () {
        this.draggable = false;
        this.resizable = false;

        this.on('resize', function () {
            this.center();
        });

        this.callParent();
    }
});

option 2:

Ext.define('Ext.window.WindowOverride', {
    override: 'Ext.window.Window',

    initComponent: function () {
        this.draggable = false;
        this.resizable = false;

        this.on('resize', function () {
            this.center();
        });

        this.callParent();
    }
});

Which approach should I follow and why?

Specifically using Extjs 4.1.1


回答1:


The second option is basically a wrapper for the first one; it will apply overrides after Ext.window.Window has been loaded.

Calling Class.override() is a relic of Ext JS 3.x days, when there was no dynamic class loading available and you had to take care of the plumbing yourself. There is no reason to use it with 4+.



来源:https://stackoverflow.com/questions/30082698/difference-between-class-override-vs-ext-defineclass-override-class

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!