javascript Angular、React 和 Blaze(客户端 Meteor)之间的主要设计差异?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/16723780/
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

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-10-27 05:44:56  来源:igfitidea点击:

Major design differences between Angular, React, and Blaze (client-side Meteor)?

javascriptdesign-patternsangularjsmeteor

提问by funkyeah

I've seen the Angular vs. React, vs Meteor questions asked a number of times. On the meteor side inevitably the answer to that question is an explanation of how meteor is much larger in scope (has DDP, deployment, all the server side stuff, and all the other things it provides).

我已经多次看到 Angular vs. React, vs Meteor 的问题。在meteor 方面,这个问题的答案不可避免地是解释meteor 的范围如何更大(有DDP、部署、所有服务器端的东西,以及它提供的所有其他东西)。

I want to restrict this question to only the Blaze engine and things where they do somewhat overlap, especially where either one may provide additional features and/or capability in terms of writing or structuring the client side code.

我想将这个问题限制在 Blaze 引擎和它们有些重叠的地方,尤其是在编写或构建客户端代码方面,任何一个都可以提供额外的特性和/或能力。

  • Where are they complementary to each other? (e.g. what does https://github.com/lvbreda/Meteor_angularjsbring to the table)
  • Assuming the above brings certain advantages, how do you compensate for that if using pure meteor?
  • Given that angular encourages a fairly strict separation of code on the client for MVC, how should one structure good code on the client in meteor to follow its MVVM pattern? (Does it just come inherently from having template, client module(s), and a model)
  • 它们在哪里互补?(例如https://github.com/lvbreda/Meteor_angularjs带来了什么)
  • 假设以上带来了一定的优势,如果使用纯流星,你如何弥补?
  • 考虑到 Angular 鼓励对 MVC 客户端上的代码进行相当严格的分离,那么应该如何在 Meteer 的客户端上构建良好的代码以遵循其 MVVM 模式?(它是否只是来自拥有模板、客户端模块和模型)

采纳答案by Bijan

Okay as far as I can tell you are asking three different questions:

好吧,据我所知,你在问三个不同的问题:

Where are they complementary to each other? (e.g. what does https://github.com/lvbreda/Meteor_angularjsbring to the table)

它们在哪里互补?(例如https://github.com/lvbreda/Meteor_angularjs带来了什么)

AngularJS is a full stack client side framework that brings ton's of features for frontend development.

AngularJS 是一个全栈客户端框架,为前端开发带来了大量功能。

The following things it brings to the table above standard meteor:

它为上面的标准流星表带来了以下内容:

  • Testing: Angular offers a complete testing framework for the client side
  • Form Validation
  • Localization
  • Components (Example: http://angular-ui.github.io/)

Assuming the above brings certain advantages, how do you compensate for that if using pure meteor?

假设以上带来了一定的优势,如果使用纯流星,你如何弥补?

If you are using pure meteor you can use almost all possible client side libraries like for example jQuery or you can code some convenience functions from angular like form validation by hand.

如果您使用的是纯流星,您可以使用几乎所有可能的客户端库,例如 jQuery,或者您可以从 angular 手动编写一些方便的函数,例如表单验证。

Given that angular encourages a fairly strict separation of code on the client for MVC, how should one structure good code on the client in meteor to follow its MVVM pattern? (Does it just come inherently from having template, client module(s), and a model)

考虑到 Angular 鼓励对 MVC 客户端上的代码进行相当严格的分离,那么应该如何在 Meteer 的客户端上构建良好的代码以遵循其 MVVM 模式?(它是否只是来自拥有模板、客户端模块和模型)

There are many ways to structure your code. Meteor is not that opinionated about code organization. You can use http://docs.meteor.com/#structuringyourappas your guidance but it really depends how you like to code. It is possible to split your code into different files in folders or to put everything into just one big file. For very small apps I prefer to keep everything in one file.

有很多方法可以构建代码。Meteor 对代码组织没有那么固执。您可以使用http://docs.meteor.com/#structuringyourapp作为指导,但这实际上取决于您喜欢编码的方式。可以将您的代码拆分为文件夹中的不同文件,或者将所有内容放入一个大文件中。对于非常小的应用程序,我更喜欢将所有内容保存在一个文件中。

I like to split my code into two folders:

我喜欢将我的代码分成两个文件夹:

  • A folder for client side stuff (subfolders like Views and Assets are sometimes a great choice)
  • A folder for server side stuff
  • 用于客户端内容的文件夹(视图和资产等子文件夹有时是一个不错的选择)
  • 服务器端东西的文件夹

If you are looking for a good practice then you can also have a look at the http://telesc.pe/source code: https://github.com/SachaG/Telescope

如果您正在寻找一个好的实践,那么您还可以查看http://telesc.pe/源代码:https: //github.com/SachaG/Telescope

回答by Andrew Mao

Abigail Watson has written a good summary of how Meteor relates to other MVC frameworks in her Meteor cookbook:

Abigail Watson 在她的 Meteor 手册中对 Meteor 与其他 MVC 框架的关系进行了很好的总结:

https://github.com/awatson1978/meteor-cookbook

https://github.com/awatson1978/meteor-cookbook

Scroll down to the "Model, View, Controllers" section.

向下滚动到“模型、视图、控制器”部分。