我有几个月的Extjs Web应用程序开发经验。我遇到了这个问题:
当我重写一个类时,我修改了方法并按照以前的实现方式调用了 callParent()
。重写部分起作用了,但是 callParent()
调用的是旧的实现。
我的重写代码
Ext.override(Ext.layout.component.Draw, {
finishedLayout: function (ownerContext) {
console.log("new layouter being overriden");
this.callParent(arguments);
}
});
需要覆盖的 Extjs 类方法:
finishedLayout: function (ownerContext) {
var props = ownerContext.props,
paddingInfo = ownerContext.getPaddingInfo();
console.log("old layouter being overriden");
this.owner.setSurfaceSize(props.contentWidth - paddingInfo.width, props.contentHeight - paddingInfo.height);
this.callParent(arguments);
}
在控制台中,我可以看到新的布局器首先打印出消息,然后是旧的布局器实现... 我设置了断点并重新跟踪调用堆栈,新布局器的callParent()
调用了旧的布局器。我需要调用父类,但不是被覆盖的方法。
有什么解决这个问题的想法吗?