结合jQuery和AngularJS [英] Combining JQuery and AngularJS

查看:130
本文介绍了结合jQuery和AngularJS的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

根据对AngularJS文档

Based on the AngularJS document

https://docs.angularjs.org/api/ng/function/ angular.element

报告说,

如果jQuery是可用的,angular.element是jQuery函数的别名。如果jQuery是不可用,angular.element代表到角的内置jQuery的子集,名为jQuery的精简版或jqLit​​e。

If jQuery is available, angular.element is an alias for the jQuery function. If jQuery is not available, angular.element delegates to Angular's built-in subset of jQuery, called "jQuery lite" or "jqLite."

这是否意味着我们可以继续前进,包括JQuery的JS文件使用jQuery选择例如 angular.element(身体)。CSS({})并使用的功能?

Does this means that we can go ahead and include JQuery JS files use the JQuery selectors like angular.element("body").css({}) and use the functions?

我测试了一下它工作正常,但我想知道

I tested that it is working fine, but I want to know

有任何正式文件/维基其中建议/不建议AngularJS组合+ JQuery的

Is there any official document/wiki which recommends/not-recommends the combination of AngularJS+JQuery

难道结合这两当有人面对一个大的性能问题?

Did anyone faced a big performance issue when combining this two?

推荐答案

AngularJS为这是伟大的。实际上它运行在其一侧,并且不与其他库干扰。你说得对,你可以使用 angular.element(身体)。CSS({})和你实际使用jQuery就像你用 $

AngularJS is great for that. It actually runs on its side and does not interfere with other libraries. You are right, you can use angular.element("body").css({}) and you are actually using jQuery just as you would with $.

业绩将是jQuery的性能损失。所以,这取决于你如何使用它。有一个在两者的结合没有性能损失。

The performance will be the jQuery performance hit. So it depends how you use it. There is no performance hit in the combining of the two.

我几乎总是使用两者结合起来,这是一个轻而易举的事。

I almost always use the two together and it's a breeze.

您一定要试试在可能的情况,虽然做的事情的角度方式。不要使用。对('点击'),但NG-点击,等等......你不应该使用比什么jQlite和角度在大多数情况下,如果是提供你做正确的事情。

You should definitely try to do things the angular way when possible though. Do not use .on('click') but ng-click, etc... You should not have to use more than what jQlite and Angular is offering in most cases if you do things right.

这篇关于结合jQuery和AngularJS的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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