之所以使用JavaScript MV *框架? [英] Reason for using a JavaScript MV* framework?

查看:98
本文介绍了之所以使用JavaScript MV *框架?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个电子商务网站,它是一个小的JavaScript密集型的(价格,品牌有条件的滤波等AJAX调用等)。
我有很多杂乱的JavaScript / jQuery的code对我的网站上(图中没有分开,没有可重用性等),并且我们打算重写code。

要解决这个问题,我碰到 KnockoutJS ,并在进一步的研究, Backbone.js的 AngularJS Ember.js

我看着最流行的网站,像这样,GitHub上,亚马逊,eBay等,似乎没有这些网站使用这些框架。

我似乎无法弄清楚是用例使用这些框架。维基百科的页面建议这些被设计用于单页的应用程序。


  1. 是否值得实施上述传统的电子商务网站?
  2. 努力
  3. 有什么缺点使用任何上述框架?

  4. 是否有一个原因,很多热门网站都没有使用它们?


解决方案

这些框架设计,让您code更容易维护和创建单页应用,以提高用户体验,在这种应用程序的导航更流畅,因为一切都是通过AJAX加载,如果你想了解更多相关信息,您可以用<一开始href=\"http://en.wikipedia.org/wiki/Single-page_application\">http://en.wikipedia.org/wiki/Single-page_application.

这种应用的另一个优点是,你将需要一个HTTP API来将所述接入点从前端数据访问层(DAL)。当你有一个HTTP API你的DAL是100%独立于数据presentation层,这意味着,在未来,你将能够重新使用它来创建其他应用例如像移动应用,你甚至可以使用工具喜欢这款手机的差距自动为您生成移动应用,如果你遵循这个方法。

您还可以保存的生成自动您的HTTP API使用工具,如 http://deployd.com/ 时间一个非常大的量。因此,我们可以说,按照此方法提供了更好的用户体验,是更快地开发,更容易维护和测试,这就是为什么它是如此受欢迎。像谷歌(angular.js)和Twitter( https://github.com/twitter/flight )大公司都在使用它,但他们只是创造了他们自己的。

如果您发现复杂,决定使用什么框架,看看到 http://todomvc.com/ 他们用同样的例子提供在每个可用的框架(一TODO应用程序),所以你可以挑选你喜欢更多之一。

希望它能帮助:)

I have a e-commerce website, and it is a little JavaScript intensive (conditional filtering for price, brands, etc. AJAX calls, etc.). I have a lot of cluttered JavaScript/jQuery code on my website (views not separate, no reusability, etc.), and we're planning to rewrite the code.

To solve the problem, I came across KnockoutJS, and on further research, Backbone.js, AngularJS, Ember.js, etc.

I looked at most of the popular websites, like SO, GitHub, Amazon, Ebay, etc. and it seems none of these websites use any of these frameworks.

What I cannot seem to figure out is the use case for using these frameworks. The wikipedia pages suggest these are designed for single page apps.

  1. Is it worth the effort to implement the above for a traditional e-commerce website?
  2. Are there any downsides to using any of the above frameworks ?
  3. Is there a reason why a lot of popular websites are not using them ?

解决方案

These frameworks are designed to make your code easier to maintain and to improve the user experience by creating single page applications, in this kind of apps the navigation is more fluid because everything is loaded via AJAX if you want to learn more about it you can start with http://en.wikipedia.org/wiki/Single-page_application.

Another advantage of this sort of applications is that you are going to need an HTTP API to be the access point to your data access layer (DAL) from the front end. When you have a HTTP API your DAL is 100% independent of the data presentation layer this means that in the future you will be able to re-use it to create other apps like for example mobile apps, you can even use tools like phone gap to auto generate the mobile apps for you if you follow this approach.

You can also save a really big amount of time auto-generating your HTTP API by using tools like http://deployd.com/. So we can say that following this approach provides a better user experience, is faster to develop and easier to maintain and test that's why it is so popular. Big companies like Google (angular.js) and twitter (https://github.com/twitter/flight) are using it but they just created their own one.

If you find complicated to decide what framework to use take a look to http://todomvc.com/ they provide with the same example (a TODO application) in each of the available frameworks so you can pick the one that you like more.

Hope it helps :)

这篇关于之所以使用JavaScript MV *框架?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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