简体   繁体   English

我可以使用sencha extjs存储和模型进行sencha touch吗?

[英]Can I use sencha extjs stores and models for sencha touch?

Can I use sencha extjs stores and models for sencha touch? 我可以使用sencha extjs存储和模型进行sencha touch吗?

I am trying to create a mobile application using sencha touch. 我正在尝试使用sencha touch创建一个移动应用程序。 I already have the application created with sencha extjs, but want to know if generally the stores and models from my extjs application will work for the sencha touch app? 我已经使用sencha extjs创建了该应用程序,但是想知道我的extjs应用程序中的商店和模型通常是否适用于sencha touch应用程序? Any ideas? 有任何想法吗?

I am using Sencha extjs 4.2 and Sencha touch 2.4 Thanks 我正在使用Sencha extjs 4.2和Sencha touch 2.4

Models in Sencha Touch 2.4 needs to have the fields inside the "config" property. Sencha Touch 2.4中的模型需要在“ config”属性内具有字段。 In the other hand, ExtJS4 can't recognize the fields when they are included in aa "config" property. 另一方面,当它们包含在“ config”属性中时,ExtJS4无法识别这些字段。

So, in my experience, models are very similar between the two platforms, but they have some small differences that you must take into account. 因此,以我的经验,两个平台之间的模型非常相似,但是您必须考虑一些小的差异。

So, in Sencha Touch: 因此,在Sencha Touch中:

Ext.define('Model1', {

extend: 'Ext.data.Model',

config: {
    fields: ['test1', 'test2']
}
});

and in ExtJS: 在ExtJS中:

Ext.define('Model1', {

extend: 'Ext.data.Model',

fields: ['test1', 'test2']
});

I think that this is the only change that you need to do (maybe if you try to customize a proxy or something like that, there are some other small changes) 我认为这是您唯一需要做的更改(也许,如果您尝试自定义代理或类似的操作,则还有一些其他小的更改)

ExtJS和Sencha Touch中通用组件的代码库非常相似,因此您可以根据需要移植一些缺少的功能,但是当我在Sencha Touch上支持项目时,我使用的模型和存储方式与ExtJS项目中相同。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM