This question already has answers here:
Best practice for overriding classes / properties in ExtJS?
(2个答案)
4年前关闭。
这2个替代之间有什么区别
所以选项1:
选项2:
我应该遵循哪种方法,为什么?
专门使用Extjs 4.1.1
(2个答案)
4年前关闭。
这2个替代之间有什么区别
所以选项1:
Ext.window.Window.override({
initComponent: function () {
this.draggable = false;
this.resizable = false;
this.on('resize', function () {
this.center();
});
this.callParent();
}
});
选项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();
}
});
我应该遵循哪种方法,为什么?
专门使用Extjs 4.1.1
最佳答案
第二个选择基本上是第一个选择的包装。加载Ext.window.Window
后,它将应用替代。
调用Class.override()
是Ext JS 3.x时代的遗物,当时没有可用的动态类加载,因此您必须自己处理管道。没有理由在4+上使用它。
关于javascript - Class.override()与Ext.define('Class'之间的区别,重写:'Class'…以创建替代,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/30082698/