Angular 2的最佳实践 [英] Best Practice of Angular 2

查看:107
本文介绍了Angular 2的最佳实践的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

Angular 2被视为前端开发中的完整框架.优点之一是,与jQuery的各种功能相比,前端交互以托管方式进行.

Angular 2 is considered as a complete framework in frontend development. One of advantages is to put frontend interactions in a managed way, in contrast to various functions of jQuery.

另一方面,jQuery非常灵活,其功能可以按需应用于每个函数.它与纯HTML代码紧密协作,特别是视觉设计师已准备好外观漂亮的模板.从这个角度来看,jQuery似乎更加敏捷.

On the other hand, jQuery is very flexible and its features can be applied on demand function by function. It is well collaborated with plain HTML codes, especially good-look templates have been prepared by visual designers. From this prospective, jQuery seems more agile.

应用Angular 2的最佳实践是什么?是否应将其与jQuery,引导程序和其他前端库/框架混合使用?他们每个人应该承担什么责任?

What is the best practice of applying Angular 2? Should it be mixed with jQuery, bootstrap, and other frontend library/framework together? What responsibility should each of them take?

推荐答案

由于此问题与软件设计有关,因此您可能会以不同的观点阅读答案,我不会假装保留最佳答案",并且会尝试坚持事实.

As this question is about software design, you may read answers with various point of views, I will not pretend to detain 'the best answer' and will try to stick with facts.

jQuery最初被设计为DOM操作库,再加上通过jQuery-ui插件的样式,再加上诸如Promises,Deferred,ajax调用之类的数据/异步管理.这些不同的功能集彼此之间的交互作用不大,而且它们可以轻松地链接在一起. jQuery不是框架而是库.

jQuery was originally designed as a DOM manipulation library, plus styling via jQuery-ui plugin, plus data/asynchronous management such as Promises, Deferred, ajax calls. These different sets of features do not interact much with each-other, besides the fact that they can be chained easily. jQuery is not a framework but a library.

  • Angular2的文档不推荐完全可以操作DOM元素.何时需要使用准则是Angular2的渲染器.
  • Angular2使用其"http"类提供ajax调用.
  • Angular2可以很好地运行rxJs Observables,Promises等,使您成为异步行为的高手.缺点是学习曲线比陡峭.
  • CSS3现在就在这里,并且很好地支持动画.可以进行类绑定来更改组件的外观.
  • Boostrap可以用于Angular2项目中,并且不需要jQuery即可运行 ,除非使用它的javascript库.
  • Angular2's documentation does not recommend manipulation of DOM elements at all. When needed guideline is to use it's Angular2's renderer.
  • Angular2 offers ajax calls using it's 'http' class.
  • Angular2 plays well will rxJs Observables, Promises, etc. allowing you to be a master of asynchronous behaviour. Downside is that the learning curve is more than steep.
  • CSS3 is now here and supports animations really well. Class binding can be done to change appearance of components.
  • Boostrap can be used in an Angular2 project, and doesn't need jQuery to run, unless using it's javascript library.

即使在项目中使用jQuery也很引人注目:

Even though, using jQuery in a project is compelling:

  • jQuery拥有辉煌的过去,学习起来非常简单,并且有很多用户.
  • 说真的,它的表现真的很好.图书馆仅占用84kb的空间.
  • jQuery有大量的插件,这些插件在angular2世界中还没有自己的继任者.例如,Boostrap'javascript'插件大部分是(如果不是全部)jQuery插件. 请参阅此处

这篇关于Angular 2的最佳实践的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆