简体   繁体   English

React 和 NodeJS 如何协同工作?

[英]How do React & NodeJS work together?

Can you tell me more about the relationship between the two?你能告诉我更多关于两者之间的关系吗? I want to (for example) write a little tool which plays audio files on my raspberry pi.我想(例如)编写一个在我的树莓派上播放音频文件的小工具。 Would I then do the player and the players interface completely in React, and then just connect to node in order to get the actual files?然后我会在 React 中完全完成播放器和播放器界面,然后连接到节点以获取实际文件吗?

Or, more generally but the same thing, if I would want to write an application that does certain things (writes files, records audio, changes system settings etc.) that would all be done in nodejs, but if I want to have an interface I would use something like React?或者,更普遍但同样的事情,如果我想编写一个应用程序来完成某些事情(写入文件、记录音频、更改系统设置等),这些事情都可以在 nodejs 中完成,但是如果我想要一个界面我会使用像 React 这样的东西吗?

I am a bit confused, but I hope this question is valid!我有点困惑,但我希望这个问题是有效的!

Node and React can be used together. Node 和 React 可以一起使用。

There is even the MERN stack that helps with that:甚至还有 MERN 堆栈可以帮助解决这个问题:

MERN is a scaffolding tool which makes it easy to build universal apps using Mongo, Express, React and NodeJS. MERN 是一个脚手架工具,可以使用 Mongo、Express、React 和 NodeJS 轻松构建通用应用程序。 It minimises the setup time and gets you up to speed using proven technologies.它最大限度地减少了设置时间,并使用经过验证的技术让您快速上手。

See: http://mernjs.org/见: http : //mernjs.org/

But you can use React with any other Node framework, not only with Express.但是您可以将 React 与任何其他 Node 框架一起使用,而不仅仅是与 Express 一起使用。 React can work with any REST API so whatever you use to build a REST API can be consumed by the frontend written in React. React 可以与任何 REST API 一起使用,因此您用于构建 REST API 的任何内容都可以由用 React 编写的前端使用。

Some other options include: Hapi, Restify, LoopBack.其他一些选项包括:Hapi、Restify、LoopBack。 For more see:更多请见:

from the official React Documentation React is "a JavaScript library for build user interfaces".来自官方React 文档React 是“用于构建用户界面的 JavaScript 库”。 In very watered down terms (and I mean watered down) React could be thought of as a templating library (please don't shoot me for that).用非常淡化的术语(我的意思是淡化)React 可以被认为是一个模板库(请不要为此向我开枪)。

What I've learned about React is it is more like the "V"iew in MVC.我对 React 的了解是它更像是 MVC 中的“V”视图。 It provides you a way to present the user interface using JavaScript and JSX.它为您提供了一种使用 JavaScript 和 JSX 呈现用户界面的方法。 With the little I know about from various tutorials, I really like working with React.由于我从各种教程中了解的很少,我真的很喜欢使用 React。

Yes, this two thinks can work together, I am currently working at such project.是的,这两个想法可以一起工作,我目前在做这样的项目。 I will point out main think here.我会在这里指出主要的想法。 That is where you put your routing.那就是你放置路由的地方。 Does it goes to Node.js server or to React Router.它是转到 Node.js 服务器还是转到 React Router。 This is important because it defines where you application logic should be.这很重要,因为它定义了应用程序逻辑应该在哪里。

ReactTS is a scaffolding engine for React on ASP.NET Core. ReactTS 是用于 ASP.NET Core 上的 React 的脚手架引擎。 Very powerful, and very fast - will generate your entire application with a single button click.非常强大,非常快速 - 只需单击一下按钮即可生成整个应用程序。 You can also customize the templates.您还可以自定义模板。 Check it out here... http://bssdev.biz/DevTools/React-Turbo-Scaffolding-Free-Download在这里查看... http://bssdev.biz/DevTools/React-Turbo-Scaffolding-Free-Download

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

相关问题 如何使 react 路由器和 nodejs/express 路由在 cpanel/共享主机中协同工作? - How to make react router and nodejs/express routes work together in cpanel/shared hosting? 概念性问题:React Native,Apollo,Node和GraphQL如何一起工作? - Conceptual question: How do React Native, Apollo, Node, and GraphQL all work together? 脚本和setTimeout / setInterval如何在NodeJS中一起工作? - How can a script and setTimeout/setInterval work together in NodeJS? 我如何一起构建反应和节点? - How do I build react and node together? Swagger、Express/Nodejs、Sequelize 如何在应用程序中组合在一起 - How do Swagger, Express/Nodejs, Sequelize fit all together in a App Nodejs和ReactJs在同一台服务器上一起工作 - Nodejs and ReactJs work together on same server 使用nodejs使Socket和rest一起工作 - Making Socket and rest to work together using nodejs React + Nodejs 如何进行生产部署? - How to do Production deployment of React + Nodejs? 让,需求和原型如何协同工作以在javascript中制作对象? - How do let, require, and prototype work together to make objects in javascript? 如何将Express和React应用程序堆叠在一起,然后在Docker中运行 - how do I stack express and react app together and then run it in docker
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM