问题
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