Angular.js vs React.js with php mvc (Laravel)
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/27587364/
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
Angular.js vs React.js with php mvc (Laravel)
提问by ctf0
I know what angular.js is and I even had a question about it @Why use AngularJs in frontend if Laravel is already used as backend?.
我知道 angular.js 是什么,我什至有一个问题@如果 Laravel 已经用作后端,为什么在前端使用 AngularJs?.
but recently I started to read about React.jsand from its site (its the V in the MVC) which is exactly what am after "handling the view and nothing else".
但最近我开始阅读React.js和它的网站(它在 MVC 中的 V),这正是“处理视图而不是其他任何东西”之后的内容。
for me, I think Angular.jsas an MVC framework was made to be used with something that is built with JavaScriptfrom start to end like Node.js
对我来说,我认为Angular.js作为一个 MVC 框架是为了与像Node.js这样从头到尾用JavaScript构建的东西一起使用
and it seems like an overkill when used with something like Larval, where I simply need something to handle the frontend and nothing else + Angularhave 2 main drawbacks
当与Larval 之类的东西一起使用时,这似乎有点矫枉过正,我只需要一些东西来处理前端,而没有其他东西 + Angular有两个主要缺点
with the latest news about a new version that won't have back compatibility with the current version makes me even feared to start learning it just to find that more or less every project out there is using the old version which mostly is true.
angular renders the whole dom if anything got changed which again is an issue for big projects.
新版本与当前版本不兼容的最新消息让我什至害怕开始学习它只是为了发现那里的每个项目或多或少都在使用旧版本,而这大部分是正确的。
如果有任何更改,angular 会渲染整个 dom,这对于大型项目来说又是一个问题。
so based on the above, plz note that I want to learn/use JS solely to enhance the user experience not to build another Gmail or Facebook and so my question is,
所以基于上述,请注意,我只想学习/使用 JS 来增强用户体验,而不是构建另一个 Gmail 或 Facebook,所以我的问题是,
could React.js be used with Laravel to handle the view and do everything Angular was going to give, or I have to use Angular liked or not?
可以将 React.js 与 Laravel 一起使用来处理视图并完成 Angular 将要提供的一切,还是我必须使用喜欢与否的 Angular?
回答by ma?ek
could React.js be used with Laravel to handle the view and do everything Angular was going to give?
React.js 可以与 Laravel 一起使用来处理视图并完成 Angular 将要提供的一切吗?
No
不
React is just for views. React components are stateful components with some really clever rendering stuff happening behind the scenes. To build a fully functional front-end app, you'd need to tie in some other code (or write it yourself).
React 仅用于视图。React 组件是有状态的组件,在幕后发生了一些非常聪明的渲染内容。要构建功能齐全的前端应用程序,您需要绑定一些其他代码(或自己编写)。
React works well with Facebook's Fluxarchitecture. I would suggest looking into that to learn how to manage the state of your react components.
React 与 Facebook 的Flux架构配合得很好。我建议研究一下以了解如何管理 React 组件的状态。
What's key to understand here is that Flux and React are not parts of a large front-end framework. React is a library and Flux (as provided by Facebook) only provides a Dispatcher. The rest is up to you to implement. There are some pre-existing implementations you can look at if you need some help to get started.
这里要理解的关键是 Flux 和 React 不是大型前端框架的一部分。React 是一个库,而 Flux(由 Facebook 提供)只提供一个 Dispatcher。剩下的由你来实施。如果您需要一些帮助才能开始,可以查看一些预先存在的实现。
What I like about flux is that it allows me implement things the way that fits my application best. React takes care of the heavy DOM lifting and is very easy to learn. Compared to Angular, I don't have to learn arbitrary conventions and gigantic APIs of a huge framework.
我喜欢 Flux 的地方在于它允许我以最适合我的应用程序的方式实现事物。React 负责繁重的 DOM 提升,并且非常容易学习。与 Angular 相比,我不必学习一个庞大框架的任意约定和庞大的 API。