javascript 我应该实际使用哪个版本的 jQuery?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/22289583/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
What version of jQuery should I actually use?
提问by
So a few months ago, there was a time I didn't actually need jQuery for anything, and almost forgot it.
所以几个月前,有一段时间我实际上不需要 jQuery 来做任何事情,而且几乎忘记了它。
Then I woke up. So, I headed to http://jquery.com/download/just to get extremely confused about what actually happened.
然后我醒了。所以,我前往http://jquery.com/download/只是为了对实际发生的事情感到非常困惑。
The last thing I remember is using version 1.8.3, and the page tells me that
我记得的最后一件事是使用版本 1.8.3,页面告诉我
The jQuery 1.x line had major changes as of jQuery 1.9.0. We strongly recommend that you also use the jQuery Migrate plugin if you are upgrading from pre-1.9 versions of jQuery or need to use plugins that haven't yet been updated.
从 jQuery 1.9.0 开始,jQuery 1.x 行发生了重大变化。如果您从 jQuery 1.9 之前的版本升级或需要使用尚未更新的插件,我们强烈建议您也使用 jQuery Migrate 插件。
Okay? The jQuery 1.x line? Well, what line was 1.9.0 then?
好的?jQuery 1.x 线?那么,1.9.0 是哪一行呢?
The 2.x notes are relatively simple to understand, if you don't need support for IE8 and under, go for it. But really, what is 1.11.0?
2.x的注释比较简单易懂,如果不需要IE8及以下的支持就去吧。但实际上,1.11.0 是什么?
- Does it support older versions of IE? 8 to be accurate.
- Do I need to use the migration plugin if I use an old plugin?
- What am I missing?
- 它是否支持旧版本的 IE?8要准确。
- 如果我使用旧插件,是否需要使用迁移插件?
- 我错过了什么?
As I have no idea of which version I should use, I'll just stick with the 1.8.3 until I know what I should use.
因为我不知道我应该使用哪个版本,所以我只会坚持使用 1.8.3,直到我知道我应该使用什么。
采纳答案by jakee
From the jQuery blog post on the releases of 1.9.0 and 2.0:
来自关于 1.9.0 和 2.0 版本的 jQuery 博客文章:
- jQuery 1.9 and 2.0 have the same API. Several deprecated features such as $.browser have been removed from both versions. It's all laid out in the jQuery 1.9 upgrade guide.
- jQuery 1.9 runs on Internet Explorer 6, 7, and 8 (“oldIE”), just like previous versions. Consider it a cleaner, slimmer, modern-API upgrade from jQuery 1.8.
- jQuery 2.0 will not run on oldIE. As a result of removing several layers of barnacle-encrusted code, it will be both faster and smaller than jQuery 1.9.
- jQuery 1.9 和 2.0 具有相同的 API。两个版本中都删除了一些不推荐使用的功能,例如 $.browser。这一切都在 jQuery 1.9 升级指南中列出。
- jQuery 1.9 可以在 Internet Explorer 6、7 和 8(“oldIE”)上运行,就像以前的版本一样。将其视为 jQuery 1.8 的更简洁、更精简、现代的 API 升级。
- jQuery 2.0 不会在 oldIE 上运行。由于删除了几层藤壶镶嵌的代码,它会比 jQuery 1.9 更快、更小。
So to answer your questions
所以回答你的问题
- 1.11.0 still supports IE 6, 7 and 8, the difference of >= 1.9.0 is in the api
- Migrate plugin can be used to detect if your code is using deprecated or removed features, maybe using it to detect whether your old plugin is using such features would be recommendable
- You were missing the blog post that explained these changes
- 1.11.0依然支持IE 6、7、8,>= 1.9.0的区别在api
- Migrate 插件可用于检测您的代码是否正在使用已弃用或已删除的功能,也许推荐使用它来检测您的旧插件是否正在使用此类功能
- 你错过了解释这些变化的博客文章
回答by Oscar Paz
If you're starting to use jQuery (you weren't using it in your project), and you need support for IE8 an earlier, use the latest version, 1.11. This version belongs to the 1.x line, as the number indicates. The only difference between 1.x and 2.x is IE support.
如果您开始使用 jQuery(您没有在您的项目中使用它),并且您需要更早的 IE8 支持,请使用最新版本 1.11。这个版本属于 1.x 行,如数字所示。1.x 和 2.x 之间的唯一区别是 IE 支持。