使用 node.js 的前端 javascript 框架
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/14072131/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Frontend javascript frameworks with node.js
提问by Juanillo
I am starting to learn frontend JavaScript frameworks like Backbone.js or Embers.js and I wanted to do some projects in Node.js. I have been reading some documentation and it seems these frameworks are used when you create an application in a single page. I'm used to developing apps which are divided into several pages and I wonder if those frameworks would be more a help or a burden to the project in my case.
我开始学习前端 JavaScript 框架,如 Backbone.js 或 Embers.js,我想用 Node.js 做一些项目。我一直在阅读一些文档,当您在单个页面中创建应用程序时,似乎会使用这些框架。我习惯于开发分成几个页面的应用程序,我想知道在我的情况下,这些框架是对项目的更多帮助还是负担。
I also wanted to know if as JavaScript is used both in the server and the client, as I use the same language if there is any kind of feature I can use to share some code between them, and if any frontend framework is more suitable for Node.js because of this.
我还想知道服务器和客户端是否都使用 JavaScript,因为我使用相同的语言,如果有任何类型的功能可以用来在它们之间共享一些代码,以及是否有任何前端框架更适合Node.js 因为这个。
回答by Om Shankar
We can't really point out a frontend framework suitable simultaneously for NodeJS applications and Frontend both.
我们无法真正指出同时适用于 NodeJS 应用程序和前端的前端框架。
A. NodeJS is essentially server side. But its JavaScript. This means all the good functional utilities like underscore.js, uglify.js, your own stuff for functionality (like a logic you might have developed for finding an item in an array in web based JavaScript), etc. can be used at the backend.
一个。NodeJS 本质上是服务器端。但它的 JavaScript。这意味着所有好的功能实用程序,如underscore.js、uglify.js、您自己的功能性东西(例如您可能为在基于 Web 的 JavaScript 中查找数组中的项目而开发的逻辑)等都可以在后端使用.
B. Frontend has evolved, and so have JavaScript Applications. Per your question, when you want to develop one page applications, you might want to look at MVC, MVVM, MVW, MVP Design Patterns. For eg. BackboneJS helps you build MVC Applications. While there are libraries like jQuery taking care of DOM, ajax and other stuff in Rich Applications, most of the time you will find the application is a combination of multiple things
乙。前端已经发展,JavaScript 应用程序也在发展。根据您的问题,当您想开发一页应用程序时,您可能需要查看 MVC、MVVM、MVW、MVP设计模式。例如。BackboneJS 帮助您构建 MVC 应用程序。虽然在 Rich Applications 中有像 jQuery 这样的库处理 DOM、ajax 和其他东西,但大多数时候你会发现应用程序是多种事物的组合
- A one-page MVC application also requires Dynamic views, and so, templating comes into picture. For eg., Ember uses Handlebars. Backbone uses underscore, etc.
- 一页 MVC 应用程序还需要动态视图,因此,模板应运而生。例如,Ember 使用Handlebars。Backbone 使用下划线等。
C. When you want to choose a framework for Frontend of your application, TodoMVCis the best to decide - http://todomvc.com/.
Ç。当您想为应用程序的前端选择框架时,TodoMVC是最好的决定 - http://todomvc.com/。
D. When you want to choose a framework for Back-end (in your case, NodeJS), you might want to look at Expressand Geddy.
If NodeJS were Plain Browser JavaScript, Express and Geddy would be Backbone - for MVC
Additionally, for NodeJS apps, the NPM registryhas enormous list of utilities, most of which are port of thingsyou have already used in Browser JavaScript
d。当您想为后端选择一个框架(在您的情况下是 NodeJS)时,您可能需要查看Express和Geddy。
如果 NodeJS 是普通浏览器 JavaScript,Express 和 Geddy 将成为主干——对于 MVC
此外,对于 NodeJS 应用程序,NPM 注册表拥有大量实用程序列表,其中大部分是您已经在浏览器 JavaScript 中使用过的东西的端口
E. A server simply serves pages and resources. As per my little knowledge therefore, even if you are using JavaScript both at backend and frontend, you would need individual efforts and files / scripts at both. The only thing you would benefit in commonis that the same frontend JavaScript developers can work on the backend with a smaller learning curve.
乙。服务器只是提供页面和资源。因此,据我所知,即使您在后端和前端都使用 JavaScript,您也需要单独的努力和文件/脚本。您唯一会受益的共同点是,相同的前端 JavaScript 开发人员可以在后端工作,学习曲线更短。
I have seen experts dropping the idea of a framework due to burden of a learning curve. At the end of the day, therefore, some research must be performed specially for an application that uses multiple technologies, and the efforts involved to learn and implement those
我见过专家因为学习曲线的负担而放弃了框架的想法。因此,归根结底,必须专门针对使用多种技术的应用程序进行一些研究,以及学习和实施这些技术所涉及的努力
回答by GautamJeyaraman
Checkout this page:
结帐此页面:
It has all the common javascript frameworks and their todo examples. Try some and figure out which is the best option for you. Hope this material helps.
它具有所有常见的 javascript 框架及其待办事项示例。尝试一些并找出最适合您的选择。希望这些材料有帮助。

