[英]Best Practice of Angular 2
Angular 2 is considered as a complete framework in frontend development. Angular 2被认为是前端开发中的完整框架。 One of advantages is to put frontend interactions in a managed way, in contrast to various functions of jQuery.
与jQuery的各种功能相比,其中一个优点是以托管方式放置前端交互。
On the other hand, jQuery is very flexible and its features can be applied on demand function by function. 另一方面,jQuery非常灵活,其功能可以按功能按需应用。 It is well collaborated with plain HTML codes, especially good-look templates have been prepared by visual designers.
它与纯HTML代码很好地协作,特别是视觉设计师准备好的模板。 From this prospective, jQuery seems more agile.
从这个角度来看,jQuery似乎更敏捷。
What is the best practice of applying Angular 2? 应用Angular 2的最佳做法是什么? Should it be mixed with jQuery, bootstrap, and other frontend library/framework together?
它应该与jQuery,bootstrap和其他前端库/框架混合在一起吗? 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 was originally designed as a DOM manipulation library, plus styling via jQuery-ui plugin, plus data/asynchronous management such as Promises, Deferred, ajax calls. jQuery最初设计为DOM操作库,加上jQuery-ui插件的样式,以及Promises,Deferred,ajax调用等数据/异步管理。 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.
jQuery不是一个框架,而是一个库。
Even though, using jQuery in a project is compelling: 即使在项目中使用jQuery也很有吸引力:
One of Angulars core ideas is not to manipulate the DOM directly, which is the core idea of jQuery to do. Angulars核心思想之一不是直接操纵DOM,这是jQuery的核心思想。 So as @GünterZöchbauer says, don't use it unless you really have to (which is very rare).
因此,@GünterZöchbauer说,除非你真的需要,否则不要使用它(这是非常罕见的)。 jQuery is more like a helper library, Angular is a Framework and should be used as such.
jQuery更像是一个帮助库,Angular是一个框架,应该这样使用。
You can of course mix it with Bootstrap, whereas you should only use the styles and use a Angular 2 version of Bootstrap though: https://valor-software.com/ng2-bootstrap/#/ or https://github.com/ng-bootstrap/ng-bootstrap . 您当然可以将它与Bootstrap混合使用,而您应该只使用样式并使用Angular 2版本的Bootstrap: https : //valor-software.com/ng2-bootstrap/#/或https://github.com / ng-bootstrap / ng-bootstrap 。
As for 至于
and other frontend library/framework together?
和其他前端库/框架在一起?
You shouldn't mix it with another Framework, that just messes things up. 你不应该把它与另一个框架混合在一起,这只会让事情变得混乱。 Libraries sure though, for most of the popular libraries out there exists (or will exist) a Angular version which comes with TypeScript support etc.
但是,对于大多数流行的库来说,库肯定存在(或将存在)带有TypeScript支持等的Angular版本。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.