What are differences between Ext.create() and Ext.define() in SenCha Touch

后端 未结 2 1722
南笙
南笙 2021-01-12 00:24

I have been learning SenCha Touch for awhile and still feel confused when trying to create a store.

In the SenCha Documentation, it says to use Ext.create() Example

相关标签:
2条回答
  • 2021-01-12 01:08

    Ext.create - to create an instance of a pre-defined class. - the class was defined using Ext.define - used to define the data and behavior of a component. which will be used later.

    Ext.define - to define your own class definition - reusable component. - instances can be created using Ext.create API.

    0 讨论(0)
  • 2021-01-12 01:13

    define is for declaring a class.

    Ext.define('Foo', {
        extend: 'Bar'
    });
    
    // Similar to:
    public class Foo : Bar {
    }
    

    create is for creating an instance:

    var o = Ext.create('Foo'); // Can also have var o = new Foo();
    
    // Similar to:
    Foo o = new Foo();
    
    0 讨论(0)
提交回复
热议问题