混合Angular.js和Bootstrap 3 - 在哪里兼容性能?性能、Angular、js、Bootstrap

2023-09-13 04:43:16 作者:月下饮茶

这是一个概念性的问题。我正在考虑加入 AngularJS 我的下一个项目,为此,我一直使用的 Twitter的引导3 UI控件。我看到其他计算器问题,一些可能的摩擦,两个框架之间,但我不太清楚什么是根本原因两者之间可能的不兼容性。

This is a conceptual question. I am considering adding AngularJS to my next project, for which I've already elected using Twitter Bootstrap 3 for UI controls. I see some possible friction in other stackoverflow questions, between the two frameworks, but am not quite sure what is the root reason for possible incompatibilities between the two.

他们都侦听事件,但自举主要是前端展现库,而在我看来,angular.js则深入得多。的也许有人可以从根本上解释了其中的不兼容性开始出现的。希望在某种程度上直接贷款,以确定它有多少是在同一个项目中混合两个是个好主意,或者,如果这样做,应避免什么。这将节省大量的时间,通过调试学习为时已晚后,或避免在首位的错误的体系结构。

They both listen to events, but bootstrap is mainly a front-end display library, whereas in my view, angular.js goes much deeper. Perhaps someone can fundamentally explain where the incompatibilities begin to arise. Hopefully in a way directly lending to determine how much it's a good idea to mix the two in the same project, or what should be avoided if doing so. This would save huge amounts of time learning through debug after it's too late, or avoiding the wrong architecture in the first place.

推荐答案

潜在的问题是,引导使用jQuery了很多它的UI功能。任何的jQuery改变不是由本身体现在角 - 例如勾选复选框使用正规的JavaScript(或jquery的)将不更新其纳克模型自动的方式,用户检查它会

The potential problem is that Bootstrap uses jQuery for a lot of its UI functionality. Anything changed by jQuery is not reflected in Angular by itself - for instance checking a checkbox using "regular" javascript (or jquery) will not update its ng-model automatically in the way a user checking it would.

我想说大多数引导插件可以做成指令,就像角表带都做。但是,这可能是一个大量的工作。有些常见的(如咆哮)也可以作为独立的角度项目在Github上。

I'd say most bootstrap plugins can be made into directives, just like Angular-strap have done. But that can be a lot of work. Some common ones (like growl) are also available as stand-alone angular projects on Github.