简体   繁体   English

JavaScript框架

[英]JavaScript Frameworks

Can someone enlighten me on web frameworks using nodejs? 有人可以使用nodejs启发我了解Web框架吗? I recently started learning express js from free code camp and while it's all going good I'm confused as to what express entirely is. 我最近开始从免费代码阵营学习express js,尽管一切都很好,但我对完全是什么感到困惑。 Is it a full stack framework? 它是一个完整的堆栈框架吗? Is it purely for backend? 纯粹是为了后端吗? I see that you can use different templating engines along with it. 我看到您可以同时使用不同的模板引擎。

I see things where people say you can use front end frameworks along with it. 我看到有人说您可以与之一起使用前端框架。 If express is able to already render views, what's the point of using a front end framework. 如果express已经能够渲染视图,那么使用前端框架的意义何在。

Also, what's the difference between express and something meteor, vuejs or react? 另外,Express和流星,Vuejs或react之间有什么区别? There's just so many buzzwords out on the web that it's confusing. 网络上有如此众多的流行词,令人感到困惑。

Express is a back-end web server framework that runs in nodejs. Express是在nodejs中运行的后端Web服务器框架。 It is purely for the back-end, though you can define routes/endpoints in it that any front-end can make ajax calls to. 尽管您可以在其中定义任何前端都可以对其进行ajax调用的路由/端点,但它仅用于后端。

You use Express to make the handling of web server requests and responses easier and fasster. 您可以使用Express使Web服务器请求和响应的处理变得更加轻松和快捷。 It has support for things like: 它支持以下内容:

  1. Defining routes/urls/endpoints that you want to handle. 定义要处理的路由/ URL /端点。
  2. Serving static web pages. 提供静态网页。
  3. Installing middleware for a wide variety of things including sessions and authentication. 安装用于多种事物的中间件,包括会话和身份验证。
  4. Hooking into one of many template rendering engines. 迷上了许多模板渲染引擎之一。
  5. Automatically parsing things like query parameters and form submissions. 自动解析查询参数和表单提交之类的内容。

Is it a full stack framework? 它是一个完整的堆栈框架吗?

No. Express does not have a front-end component. 否。Express没有前端组件。

Is it purely for backend? 纯粹是为了后端吗?

Yes. 是。

Because Express has become so popular, there are also thousands of add-ins that can plug into express (often as middleware) for things like sessions or authentication. 由于Express变得如此流行,因此还有成千上万的插件可以插入Express(通常作为中间件)来进行会话或身份验证之类的操作。

Since it handles standard HTTP requests, you can use it with any front-end technology from just a plain browser to the many front-end frameworks. 由于它处理标准的HTTP请求,因此您可以将其与任何前端技术一起使用,从简单的浏览器到许多前端框架。

Also, what's the difference between express and something meteor, vuejs or react? 另外,Express和流星,Vuejs或react之间有什么区别?

Express is a back-end framework (runs on the web server). Express是一个后端框架(在Web服务器上运行)。 vuejs and react are front-end libraries (run in the browser). vuejs和react是前端库(在浏览器中运行)。 Meteor is a full-stack framework. 流星是一个全栈框架。 On the back-end, it runs on nodejs and the front-end component runs in the browser. 在后端,它在nodejs上运行,而前端组件在浏览器中运行。

I see things where people say you can use front end frameworks along with it. 我看到有人说您可以与之一起使用前端框架。 If express is able to already render views, what's the point of using a front end framework. 如果express已经能够渲染视图,那么使用前端框架的意义何在。

Yes, Express can serve the web pages you view and it can use a server-side template engine to render them. 是的,Express可以为您查看的网页提供服务,并且可以使用服务器端模板引擎来呈现它们。 But, there's potentially a lot more to a front-end framework than that. 但是,前端框架可能不止于此。 For example, express provides nothing to manage a user's interaction with a page in the browser or the building of dynamic web pages that change based on user interaction. 例如,express没有提供任何内容来管理用户与浏览器中页面的交互或基于用户交互而变化的动态网页的构建。 If you're building web pages that create, read and update data from a database, then Express by itself provides no automation for doing that while other frameworks can offer a lot of help with that. 如果您要构建从数据库创建,读取和更新数据的网页,那么Express本身不会提供自动化的方法,而其他框架可以为此提供很多帮助。 You could build all that in your own JavaScript that would live in the web pages that Express was serving, but Express provides no help with that at all other than just delivering the JavaScript that you wrote on your own. 您可以在自己的JavaScript中构建所有内容,而这些JavaScript可以存在于Express所服务的网页中,但是Express并没有提供任何帮助,仅提供了您自己编写的JavaScript。

If you want to know more about what front-end frameworks do, then I'd suggest you read about frameworks like react, vuejs or angular to understand their value proposition. 如果您想进一步了解前端框架的功能,那么我建议您阅读一下诸如React,Vuejs或angular这样的框架,以了解它们的价值主张。 I'm not saying that you have to use a front-end framework (because you do not). 我并不是说您必须使用前端框架(因为您不需要)。 There are zillions of sites on the web that consist of some sort of back-end framework and then plain JS/HTML web pages. 网络上有无数的网站,其中包含某种后端框架,然后是普通的JS / HTML网页。 Whether a front-end framework would benefit your development depends on what you're doing and how well it aligns with what a particular front-end framework offers. 前端框架是否会对您的开发有所帮助,取决于您在做什么以及与特定前端框架提供的内容是否保持一致。

Here are a couple good articles about what reactjs is: 这是一些关于什么是reactjs的好文章:

ReactJS For Stupid People (fyi, I found it a very good article for smart people too). ReactJS对于愚蠢的人 (仅供参考,我也发现它对聪明的人来说也是非常好的文章)。

What is React.js and Why I recommend it to other JavaScript Developers? 什么是React.js,为什么我推荐给其他JavaScript开发人员?

This article Full-Stack Frameworks contains a useful discussion of pre-built full-stack functionality such as Meteor vs. using a combination of technology such as MEAN (Mongo + Express + AngularJS + Node.js) or MERN (Mongo + Express + React + Node.js) and also touches on which technologies are more commonly used together. 本文的全栈框架包含有关流星之类的预建全栈功能的有用讨论,以及结合使用MEAN(Mongo + Express + AngularJS + Node.js)或MERN(Mongo + Express + React)等技术的组合的有用讨论+ Node.js),还介绍了哪些技术更常用。

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

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