使用 JavaScript MV* 框架的原因? [英] Reason for using a JavaScript MV* framework?

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

问题描述

我有一个电子商务网站,它是 JavaScript 密集型的(价格、品牌等条件过滤.AJAX 调用等).我的网站上有很多杂乱的 JavaScript/jQuery 代码(视图不是分开的,没有可重用性等),我们正计划重写代码.

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.

为了解决这个问题,我遇到了KnockoutJS,并进一步研究了Backbone.jsAngularJSEmber.js

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

我查看了大多数流行网站,例如 SO、GitHub、Amazon、Ebay 等,但似乎这些网站都没有使用任何这些框架.

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. 为传统电子商务网站实施上述工作是否值得?
  2. 使用上述任何框架有什么缺点吗?
  3. 许多流行网站不使用它们是否有原因?

推荐答案

这些框架旨在通过创建单页应用程序使您的代码更易于维护并改善用户体验,在此类应用程序中,导航更加流畅因为一切都是通过 AJAX 加载的,如果您想了解更多信息,可以从 http://en.wikipedia.org/开始wiki/Single-page_application.

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.

此类应用程序的另一个优点是您将需要一个 HTTP API 作为从前端到您的数据访问层 (DAL) 的访问点.当您拥有 HTTP API 时,您的 DAL 100% 独立于数据表示层,这意味着将来您将能够重新使用它来创建其他应用程序,例如移动应用程序,您甚至可以使用电话间隙等工具如果您按照这种方法自动生成移动应用程序.

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.

您还可以通过使用诸如 http://deployd.com/ 之类的工具来节省大量时间来自动生成您的 HTTP API.所以我们可以说,遵循这种方法提供了更好的用户体验,开发速度更快,维护和测试更容易,这就是它如此受欢迎的原因.Google (angular.js) 和 twitter (https://github.com/twitter/flight) 等大公司正在使用它,但他们只是创建了自己的.

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.

如果您觉得决定使用什么框架很复杂,请查看 http://todomvc.com/ 他们提供了相同的示例(一个 TODO 应用程序)在每个可用的框架中,因此您可以选择您更喜欢的一个.

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.

希望有帮助:)

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

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