煎茶触摸VS Backbone.js的 [英] Sencha Touch Vs Backbone.js

查看:108
本文介绍了煎茶触摸VS Backbone.js的的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有什么根本区别煎茶触摸和Ba​​ckbone.js的,实际上已经建立了一个Backbone.js的项目,但不知道煎茶触摸的。我对建了PhoneGap的应用程序,一个是是什么?

What are the basic difference Sencha Touch and Backbone.js, actually have built a project in backbone.js but not aware of Sencha Touch. I have to built a PhoneGap application which one is better for that?

推荐答案

煎茶触摸(我们的产品),旨在成为一个全功能于一身的应用程序框架,它提供了你需要创建美观的应用程序的所有功能。一切都被设计成在所有主要的移动浏览器都一起工作。这是一个干净架构的面向对象的方法来开发应用程序。

Sencha Touch (our product) is intended to be an all-in-one application framework that provides all the functionality you need to create great looking apps. Everything is designed to work all together on all the major mobile browsers. It's a cleanly architected object-oriented approach to developing apps.

作为一个全合一的框架,它为您提供了一套完整独立的分辨率的UI部件(旋转木马,列表,标签,工具栏等等,等等)的MVC库,事件管理,工具库,动画,主题系统,对象生命周期管理,布局系统,图纸和图表库和更多的东西比你都不能动摇棍子在...因为这一切都设计为一起工作,最初的学习是高,但一旦你再有人们发誓这是光年比什么都更富有成效。

As an "all-in-one" framework, it gives you a full set of resolution-independent UI widgets (carousels, lists, tabs, toolbars, etc. etc.) an MVC library, event management, utility libraries, animation, a theming system, object lifecycle management, a layout system, a drawing and charting library and more stuff than you can shake a stick at... Because it's all designed to work together, the initial learning is higher, but once you're there people swear it's light-years more productive than anything else.

VS

Backbone.js的,这是一个简单的MVC库。这是关于1000 $ C $行C并为您提供5类:

Backbone.js, which is a simple MVC library. It's about 1,000 lines of code and gives you 5 classes:


  • 模型

  • 查看

  • 路由器

  • 收藏

  • 活动

它有underscore.js实用功能的依赖,所以你需要这一点。你也可能需要使用单独的模板库,以及一个DOM抽象/处理库像jQuery或jQuery Mobile的里面也有一些UI部件和很多其他的库来构建一个完整的应用程序。但有些人preFER研究和手策划他们的个人图书馆。

It has a dependency on underscore.js for utility functions, so you'll need that too. You will also probably need to use a separate templating library as well as a DOM abstraction/manipulation library like jQuery or jQuery Mobile which also has some UI widgets and a bunch of other libraries to build a full app. But some people prefer to research and hand-curate their individual libraries.

更新:我想添加更多的细节repond低于本主教的答案。亚伦康兰,谁是我们的煎茶建筑师引线和煎茶无期徒刑帮助我这个加法。

Update: I wanted to add more detail to repond to Ben Bishop's answer below. Aaron Conran, who's our Sencha Architect lead and a Sencha lifer has helped me out with this addition.

有是煎茶和骨干之间有一定的世界观的差异。一般情况下,煎茶往往停留在JS世界,我们期待您的JS会产生你的HTML内容。在另一方面骨干是种HTML和JS之间的混杂的。有没有添油加醋理由使用一个或另一个,虽然我们认为,任何复杂的数据驱动的应用程序更好地由煎茶方式送达。好吧上的细节。

There is a definite world view difference between Sencha and backbone. In general, Sencha tends to stay in the JS world and we expect that your JS will generate your HTML content. Backbone on the other hand is kind of a mishmash between an HTML and JS. There's no cut and dry reason to using one or the other, although we believe that data-driven apps of any complexity are better served by the Sencha approach. Ok on to details.

第一关重:类,声明中JS一类本的例子就是把每一个属性和方法的副本中的对象的每个实例。在原始的JavaScript通常情况下工作,你希望让他们跨类 MyClass的的实例共享把这些在原型。该煎茶类系统将自动为您完成此。

First off re: Classes, Ben's example of declaring a class in JS would put a copy of every property and method in every instance of the object. Typically working in raw JavaScript, you want to put these on the prototype so that they are shared across instances of the class MyClass. The Sencha class system does this automatically for you.

此外在原始的JavaScript,用户必须以正确继承或某一类混合正确神交原型继承。煎茶负责FO thsi没有你不必担心。

Additionally in raw JavaScript, users have to grok prototypical inheritance correctly in order to properly inherit from or mix in a particular class. Sencha takes care fo thsi without you having to worry.

至于神奇字符串去(虽然我认为这是一个相当负面的特性),你没有,如果你不喜欢4.x中他们使用它们,而是你可以使用Ext.extend直接标识符(尽管这是自4.0.0 <一个pcated正式去$ p $ href=\"http://docs.sencha.com/touch/2-1/#!/api/Ext-method-extend\">http://docs.sencha.com/touch/2-1/#!/api/Ext-method-extend).

As far as "magic strings" go (although I'd argue that's a rather negative characterization) you don't have to use them if you don't like them in 4.x , instead you can use Ext.extend with direct identifiers (although this is officially deprecated since 4.0.0 http://docs.sencha.com/touch/2-1/#!/api/Ext-method-extend).

使用魔法的字符串是在几个方面是有用的。

Using magic strings is useful in a few ways.

首先,我们可以少担心依赖顺序,当任何一类定义/从延长。这一点很重要在复杂的应用

First off we can worry less about dependency order and when any class is defined/extended from. This matters in complex apps

例如

Ext.define('Turtle', { extend: 'Animal' }); 
Ext.define('Animal', { });

的作品,因为煎茶等待,直到动物类定义甲鱼类中定义。

Works because Sencha waits until the Animal class is defined before defining the Turtle class.

在对比:

Turtle = Ext.extend(Animal, {
});
Animal = Ext.extend({}, {
});

一点儿也不工作,因为我们无法找到变量引用的动物。

Does'nt work because we can't find the variable reference Animal.

二,使用字符串意味着我们可以支持动态加载。例如,如果我们有

Second, using strings means we can support dynamic loading. For example if we have

Ext.define('MyApp.foo.MyClass', {
    extend: 'MyApp.foo.ParentClass'
});

如果你遵循严格的类名JS文件约定,类装载器知道在何处即加载类:

If you follow a strict class name to JS folder convention, the class loader knows where to load the class namely:


  • MyApp.foo.MyClass住在app /富/ MyClass.js

  • MyApp.foo.ParentClass住在app /富/ ParentClass.js

该技术很容易让煎茶做的有益的事情:
  - 类管理器将自动无需您创建和放大器创造合适的对象;管理名称空间
  - 确定任何类或实例的类名
Ext.ClassManager.getName(将myInstance) - >MyApp.foo.MyClass

This technique makes it easy for Sencha to do useful things: - The class manager will automatically create proper objects without you having to create & manage namespaces - Determine the classname of any class or instance Ext.ClassManager.getName(myInstance) -> "MyApp.foo.MyClass"


  • 在一个特定的类定义执行一些动作

  • Perform some action when a particular class is defined

Ext.ClassManager.onCreated(函数(){
},范围,'MyApp.foo.MyClass');

Ext.ClassManager.onCreated(function() { }, scope, 'MyApp.foo.MyClass');

支持改写命名空间,例如,如果你需要同时在同一页面中运行相同的组类的两个版本...你可以煎茶触摸的外部顶层命名空间的命名空间改写为别的东西。

Support namespace rewriting, for example if you need to run two versions of the same set of classes concurrently in the same page... you can rewrite the namespace of Sencha Touch's "Ext" top level namespace to something else.

好吧,到模板。
在煎茶模板系统,用户可以嵌入任何HTML标签内的模板,它不会跟着一起渣土:(以煎茶的情况下,一个textarea或更典型)

Ok, on to Templates. In the Sencha templating system, users can embed their templates within any HTML tag that won't muck with it: for example script tags with a custom type (or more typically in Sencha's case a textarea)

var myTpl = Ext.XTemplate.from('theIdOfMyTpl')

您也可以将您的模板在单独的文件,并通过XHR加载它们。虽然我们一般建议你写在服务器端的东西来管理这为良好的业绩。

You can also store your templates in separate files and load them via an XHR. Though we generally recommend you write something on the server side to manage this for good performance.

重:IDE的
煎茶建筑师自动处理这些东西开箱(包括它在项目中引用的任何地方,等)。我相信我们的Eclipse插件也可以处理它,但我要检查。

re: IDE's Sencha Architect handles this stuff automatically out of the box (including any places it's referenced in the project, etc). I believe our Eclipse plugin also handles this, but I'd have to check.

这篇关于煎茶触摸VS Backbone.js的的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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