Error upgrading from ExtJs3 to ExtJs4-''me

2019-08-10 17:48发布

问题:

I'm updating my project from Ext3.3 to Ext4.
I have added the ext3-core-compat.js and ext3-compat.js files after added the new ext4 ext-all-debug.js file.

I am getting a members is udefined error on line 3262 of ext-all-debug.js.
Which is inside the Ext.extend method which accepts 3 parameters:

Ext.extend = function(subclass, superclass, members) 

i can see from the ExtJs4 documentation that Ext.extend is deprecated, however I just want to get my code working before I change all of my Ext.extend to Ext.define.

Any help guys?

回答1:

I assume that you're using the anonymous constructor syntax, like this?

MyClass = function(config) {
    ...
}
Ext.extend(MyClass, SomeOtherClass, {
    ...
});

If so, this form cannot be detected by Ext4 or the compat layer and must be updated manually to the new standard Ext.define syntax. I'm not sure if this is currently mentioned in the migration documentation, and if not I'll add it.



回答2:

Assuming that you have followed the steps in the ExtJS 3 to 4 migration guide, I don't think that there is much else that can be done other than to manually go through your application and make the changes. According to Sencha's blog post on the migration (emphasis mine):

Ext JS 3 Compatibility Layer

This consists of a set of files that, when included after Ext JS 4, provide overrides that will bootstrap existing Ext JS 3 code to run under Ext JS 4. The goal of this layer is not to enable your application to run unmodified under Ext JS 4 long-term. On the contrary, you should expect to use this layer only as a temporary means of migrating fully to Ext JS 4. The purpose of providing it is to help make the transition as swift and painless as possible. Rather than debugging obscure errors from a blank screen, you will be able to get your application back into a rendered and functional state much more quickly using the compatibility layer, making it dramatically easier to start migrating to the latest architecture.