简体   繁体   English

Angular 2中的多个UI组件库

[英]Multiple UI component libraries in Angular 2

I'm new to Angular 2+. 我是Angular 2+的新手。 From Angular resource page got to know different UI components library. 从Angular 资源页面了解了不同的UI组件库。 Is it possible to use multiple UI components library for better look of UI such as one UI for data-grid , another for side-menu ? 是否可以使用多个UI组件库来更好地查看UI,例如一个用于数据网格的UI,另一个用于侧面菜单? How to do it then? 怎么办呢?

It is indeed possible, but not recommended. 这确实是可能的,但不推荐。

You should consider using a unique UI component library for a couple of reasons: 您应该考虑使用唯一的UI组件库,原因如下:

  • Design patterns may conflict from one library to another. 设计模式可能会从一个库冲突到另一个库。
  • It is generally not recommended to use two different UI component libraries as they may create conflicts (for example Bootstrap 4 may conflict with Angular Material 2 because bootstrap uses a grid system that is based on CSS display table and Angular Material is using display flex, if I recall). 通常不建议使用两个不同的UI组件库,因为它们可能会产生冲突(例如Bootstrap 4可能与Angular Material 2冲突,因为bootstrap使用基于CSS显示表的网格系统,而Angular Material正在使用display flex,如果我记得)。

If you truly wish to do it, then you should simply try to go through the "Get started" or installation process of each UI Components and use them as you wish. 如果您真的希望这样做,那么您应该尝试通过每个UI组件的“入门”或安装过程并根据需要使用它们。

Links for Angular Material 2 & Bootstrap 4 respectively. 分别为Angular Material 2Bootstrap 4的链接。

主要冲突是主题/风格相关的,例如,不同ui库中的按钮可能具有非常不同的外观。

It is possible but it is recommended to stick to one UI library. 这是可能的,但建议坚持使用一个UI库。

To give you an example, here's 2 UI libraries. 举个例子,这里有2个UI库。 Angular Material and ngx-bootstrap ( For instructions on how to add it to your project, just go to their official pages ) Angular Materialngx-bootstrap (有关如何将其添加到项目中的说明,请转到他们的官方页面)

Let's say I want to use the md-card from angular material. 假设我想使用角度材料的md卡 My template would look something like this 我的模板看起来像这样

<md-card>
I'm from angular material.
</md-card>

Now I want to use the datepicker from bootstrap. 现在我想使用bootstrap中的datepicker I can just insert it like this 我可以像这样插入它

<md-card>
 I'm from angular material.
  <datepicker [(ngModel)]="dt"></datepicker>
 </md-card>

You have now two different ui libraries, but as you can imagine, the design might not be desireable. 你现在有两个不同的ui库,但是你可以想象,设计可能并不理想。

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

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