简体   繁体   English

Angular 2 Bootstrap 4和ng-bootstrap

[英]Angular 2 Bootstrap 4 and ng-bootstrap

如果我们可以直接使用bootstrap 4类(使用容器和模态?),我一直在使用ng-bootstrap和bootstrap 4语法,我对如何对由angular团队构建的ng-bootstrap的需要感到困惑。各种各样的地方没有特别的原因,它变得一团糟......是否有一般规则使用?

One of the main reasons for using ng-bootstrap would be the JavaScript compatibility part . 使用ng-bootstrap的主要原因之一是JavaScript兼容性部分

The regular Twitter Bootstrap relies on jQuery for data manipulation. 常规的Twitter Bootstrap依赖于jQuery来进行数据操作。 It also manipulates the state of elements by setting classes such as ".active" or by removing it from an existing element. 它还通过设置诸如“.active”之类的类或通过从现有元素中删除它来操纵元素的状态。

On the other hand, ng-bootstrap does NOT require jQuery to run. 另一方面,ng-bootstrap不需要运行jQuery。 All the elements are built from ground up using code that would not require jQuery and would play nicely along with Angular Core. 所有元素都是使用不需要jQuery的代码从头开始构建的,并且可以与Angular Core一起很好地运行。 It also helps retain the look and feel of Bootstrap components by making use of Bootstrap CSS file. 它还有助于通过使用Bootstrap CSS文件来保留Bootstrap组件的外观和感觉。

To summarize, if you use Twitter Bootstrap, you rely solely on jQuery for JavaScript. 总而言之,如果您使用Twitter Bootstrap,则仅依赖于jQuery for JavaScript。 When you are using ng-bootstrap, you are moving away from jQuery domain completely and you would be relying purely on AngularJS to provide you with the functionality part of it. 当你使用ng-bootstrap时,你正在完全脱离jQuery域,你将纯粹依赖AngularJS来为你提供它的功能部分。 The only thing that ng-bootstrap and Twitter Bootstrap have in common would be the CSS styling for the elements. ng-bootstrap和Twitter Bootstrap唯一共同点就是元素的CSS样式。

Hope this clears the confusion. 希望这清除了混乱。

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

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM