我使用 ExtJs 4.1 和 DeftJs。
一些类是用这样的构造函数定义的:
Ext.define( 'A.helper.Report', {
config: {
conf : null,
viewMain : null
},
constructor: function( oConfig ) {
this.conf = oConfig.conf;
this.viewMain = oConfig.viewMain;
this.initConfig( oConfig );
}
...
现在,我像这样创建这个类的几个实例:
var class1 = Ext.create( 'A.helper.Report', {
conf: someValue,
viewMain: someObject
} );
var class2 = Ext.create( 'A.helper.Report', {
conf: otherValue,
viewMain: otherObject
} );
使用这些实例时,虽然给了它们不同的oConfig数据,但现在两者class1都有class22nd 的数据oConfig。
因此,在两种情况下都调用时this.conf,我得到someValue.
如何保留已创建实例的数据?
解决方案:
我写
Ext.define( 'A.helper.Report', {
...
references: {}
...
并将我的实例放在那里,覆盖旧实例。
切换到references: null帮助。
...