仅使用 Jquery 而不是 AngularJS 会使应用程序对 IE 友好吗?

Using only Jquery instead of AngularJS will make an app IE friendly?

我正在 AngularJS 中开发和应用程序,此应用程序有一个页面,必须由使用 Internet Explorer 8(可能更旧)的人使用。

仅使用 Jquery 而不是 Angular + Jquery(因为我知道 Angular 需要 Jquery)是否会使页面对 Internet Explorer 更友好?或者我会失去更多的功能吗?

开始回答,Angular doesn't actually require jQuery。它有一个名为 jQuery lite or jqLite-

jqLite is a tiny, API-compatible subset of jQuery that allows Angular to manipulate the DOM in a cross-browser compatible way. jqLite implements only the most commonly needed functionality with the goal of having a very small footprint.

return 构成您问题主旨的兼容性问题。

Angular JS 文档明确指出从 1.3 版本开始不支持 Internet Explorer 8 -

AngularJS 1.3 has dropped support for IE8. Read more about it on our blog. AngularJS 1.2 will continue to support IE8, but the core team does not plan to spend time addressing issues specific to IE8 or earlier.

关于 Internet Explorer 兼容性的主题,它还指出-

The project currently supports and will attempt to fix bugs for IE9 and above. The continuous integration server runs all the tests against IE9, IE10, and IE11...

We do not run tests on IE8 and below. A subset of the AngularJS functionality may work on these browsers, but it is up to you to test and decide whether it works for your particular app.

两者的来源 - Internet Explorer Compatibility, Angular JS Developer Guide

鉴于 Internet Explorer 版本 8 和 9 之间 API 和 DOM 的重大变化 - 我发现 Angular 1.3 仅通过包含在Internet Explorer 8 中的一个页面,尽管 1.X 分支中的 jQuery 版本提供的抽象可以防止出现问题,前提是它在 之前加载 Angular JS(或至少在触发 DOMContentLoaded 事件之前),从而确保使用它代替内置的 jQuery lite provided with Angular JS。考虑到 jqLit​​e 中包含的 DOM 选择器和事件绑定函数,这大概是兼容性问题的最可能来源。

如果您的应用程序需要 运行 在 Internet Explorer 8 中,您最好使用最新的遗留 1.2 版本 - 在撰写本文时为 1.2.28。

jQuery 对于您的项目来说应该是安全的,前提是您使用 1.x 分支而不是简化的 2.x 分支,它在 browser support 上有一个很好的页面,您应该想确认一下。

在撰写本文时,1.x 分支维持对 Internet Explorer 6 的支持,并针对该浏览器进行了单元测试。 2.x 分支具有相同的 API,但删除了对 Internet Explorer 9 之前版本的支持 - 以减少 jQuery 方法所需的非标准 Internet Explorer API 解决方法上班。

期待 3.x 版本,具有相同 APIs 的拆分 1.x/2.y 将被单个 3.x 版本号取代 - 并且一个单独的 "compatibility" branch/file 将同时可用于支持更广泛的浏览器。在 blog post announcing the release 中,Internet Explorer 8 被专门检查为受支持,并且根据当前的 StatCounter 数据,Internet Explorer 8 仍然享有 3.43% 到 5.49% 的支持率 - 您在项目中使用 jQuery 仍然应该是安全的在可预见的未来。

简答

jQuery 提供与 Angular JS 截然不同的功能,并且 - 尽管可以重写 AngularJS 应用程序以仅使用 jQuery,但它会更更详细地实现某些行为。我不打算在这里详细介绍 Angular JS 与 jQuery 的不同之处,而是让您参考他们的 Developer Guide Introduction.

jQuery 库比 AngularJS 享有更广泛的引用兼容性,但 AngularJS 的 1.2 版本仍然支持 Internet Explorer 8。如果你想使用 Angular 那么如果 Internet Explorer 8 是您需要支持的最早版本,那么您应该能够安全地使用该版本。

如果您想要尽可能广泛的兼容性,那么您应该为您的应用程序使用 jQuery 而不是 Angular JS。尽管 Internet Explorer 6 和 7 在 2014 年 12 月的全球使用率合计仅为 0.36%,但如果您希望使用它,Angular 似乎是一个合理的决定。

一如既往,在依赖全球统计数据之前检查您的目标 market/demographic 的要求。