我可以将 jQuery UI 1.12.1 与 jQuery 3.x 一起使用吗?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/40493815/
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

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-26 17:15:02  来源:igfitidea点击:

Can I use jQuery UI 1.12.1 with jQuery 3.x?

jqueryjquery-ui

提问by Dennis

I changed my jQuery 1.7.2to 3.1.1and changed my jQuery UI from version 1.8.16to version 1.12.1.

我将 jQuery 更改1.7.23.1.1并将我的 jQuery UI 从 version 更改1.8.16为 version 1.12.1

Quite a few of my existing JS stuff broke, like styling of buttons, and dialogbehaves in unexpected manner, i.e. half of modal dialog is covered up by the mysterious <div class="ui-widget-overlay ui-front"></div>

我现有的很多 JS 东西都坏了,比如按钮的样式,并且dialog行为方式出乎意料,即模态对话框的一半被神秘的东西掩盖了<div class="ui-widget-overlay ui-front"></div>

I suspected jQuery UI to be at fault due to the covering above. I went to jQuery UI site and I see that stable version is for jQuery 1.7+.

由于上面的覆盖,我怀疑 jQuery UI 有问题。我去了 jQuery UI 站点,我看到稳定版本适用于jQuery 1.7+.

Does that mean that I should be using jQuery 1.x with jQuery UI, or can I use jQuery 3.x okay (plus ... try to figure out why my styling and functionality broke)?

这是否意味着我应该将 jQuery 1.x 与 jQuery UI 一起使用,或者我可以使用 jQuery 3.x 吗(加上...尝试找出为什么我的样式和功能会损坏)?

采纳答案by jeanfrg

jQueryUI supports the following jQuery version range:

jQueryUI 支持以下 jQuery 版本范围:

"dependencies": {
    "jquery": ">=1.7.0 <4.0.0"
},

I'd say you're good to go.

我会说你很高兴去。

Source: https://github.com/jquery/jquery-ui/blob/master/package.json#L53

来源:https: //github.com/jquery/jquery-ui/blob/master/package.json#L53

It might be that you're seeing a lot of broken components because either you're not importing their CSS or you're overriding their CSS.

可能是因为您没有导入它们的 CSS 或覆盖了它们的 CSS,因此您看到了许多损坏的组件。

回答by Harm

Can you use jQuery-UI with jQuery 3.2.1 ?

你能在 jQuery 3.2.1 中使用 jQuery-UI 吗?

Imho you can not without having serious problems. See the given example below.

恕我直言,你不能没有严重的问题。请参阅下面给出的示例。

Assume the following configuration:

假设以下配置:

  • jQuery 3.2.1 (CDN)
  • jQuery UI 1.12.1 (CDN)
  • Detection jQ Migrate 3.0.0 for error detection.
  • jQuery 3.2.1 (CDN)
  • jQuery UI 1.12.1 (CDN)
  • 检测 jQ Migrate 3.0.0 用于错误检测。

I get the following errors:

我收到以下错误:

  • jQuery.expr[":"] is now jQuery.expr.pseudos in jquery-ui.min.js
  • jQuery.expr.filters is now jQuery.expr.pseudos in query-ui.min.js
  • jQuery.unique is deprecated, use jQuery.uniqueSort
  • jQuery.expr[":"] 现在是 jquery-ui.min.js 中的 jQuery.expr.pseudos
  • jQuery.expr.filters 现在是 query-ui.min.js 中的 jQuery.expr.pseudos
  • 不推荐使用 jQuery.unique,使用 jQuery.uniqueSort