我们可以在我们的Web应用程序中同时使用jQuery和AngularJS吗? [英] Can we use both jQuery and AngularJS in our web application?

查看:79
本文介绍了我们可以在我们的Web应用程序中同时使用jQuery和AngularJS吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我们可以在Web应用程序中同时使用jQuery和AngularJS吗?我读过一些建议,说不要在您的项目中同时使用这两个建议,因为每个都有不同的生命周期.

Can we use both jQuery and AngularJS in our web application? I have read some advice saying not to use both together in your project, because each has a different lifecycle.

我们的要求是使用ASP.NET WebApi和AngularJS构建响应式Web应用程序;现在,为了使我们的应用程序具有响应性,我们希望使用Bootstrap,并且Bootstrap同时需要Bootstrap CSS和jQuery库;那么我们应该将jQuery库和AngularJS库都添加到我们的项目中吗?

Our requirement is to build a responsive web application using ASP.NET WebApi and AngularJS; now to make our application responsive we wish to use Bootstrap, and Bootstrap requires both Bootstrap CSS and the jQuery library; so should we add both the jQuery libary and the AngularJS library to our project?

推荐答案

可以,但是不建议这样做,因为jQuery会增加很多开销. 如果要编写角度方式",则不会破坏角度功能.像示例一样,如果您尝试调整字段的值,那么在您手动触发摘要之前,范围不会更新.它导致垃圾代码和行为不一致.

Yes you can but it's not recommended because jQuery adds alot overhead. If you would code the "angular way", then you won't break the angular functionality. Like example if you try to adjust a value of a field, then your scope wouldn't update until you manually trigger a digest. It leads into rubbish code and inconsistent behavior.

Angular是否使用jQuery库?

是的,当应用程序中存在Angular时,Angular可以使用jQuery. 正在引导应用程序.如果您的网站中不存在jQuery 脚本路径,Angular会退回到其自己的实现 我们称为jQLite的jQuery子集.

Yes, Angular can use jQuery if it's present in your app when the application is being bootstrapped. If jQuery is not present in your script path, Angular falls back to its own implementation of the subset of jQuery that we call jQLite.

Angular 1.3仅支持jQuery 2.1或更高版本.的jQuery 1.7 较新的版本可能可以与Angular一起正常使用,但我们不保证.

Angular 1.3 only supports jQuery 2.1 or above. jQuery 1.7 and newer might work correctly with Angular but we don't guarantee that.

来源

也看到以下问题:我们应该在AngularJS中使用jQuery吗?

如果您真的确定要使用jQuery,请确保首先包含jQuery脚本.然后,Angular将加载jQuery代替JQ lite.

If you are really really sure that you want to use jQuery, make sure that you include the jQuery script first. Angular will load jQuery in place of JQ lite then.

这篇关于我们可以在我们的Web应用程序中同时使用jQuery和AngularJS吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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