SenCha Touch 中的 Ext.create() 和 Ext.define() 有什么区别 [英] What are differences between Ext.create() and Ext.define() in SenCha Touch

查看:25
本文介绍了SenCha Touch 中的 Ext.create() 和 Ext.define() 有什么区别的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经学习 SenCha Touch 一段时间了,但在尝试创建商店时仍然感到困惑.

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

在 SenCha 文档中,它说使用 Ext.create() 示例我试过了,它根本不起作用.

In the SenCha Documentation, it says to use Ext.create() Example I tried and it simply doesn't work.

对于其他人,我总是看到人们使用 Ext.define() 来创建商店并且它有效.

For the rest of others, I always see people use Ext.define() to create a store and it works.

现在,我的问题是:它们之间有什么区别以及何时/如何以正确的方式使用它们中的任何一个?

Now, my question is: what are the differences between them and when/how to use either one of them in a right way?

非常感谢一些演示代码

非常感谢我的朋友们.

推荐答案

define 用于声明一个类.

Ext.define('Foo', {
    extend: 'Bar'
});

// Similar to:
public class Foo : Bar {
}

create 用于创建实例:

var o = Ext.create('Foo'); // Can also have var o = new Foo();

// Similar to:
Foo o = new Foo();

这篇关于SenCha Touch 中的 Ext.create() 和 Ext.define() 有什么区别的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆