简体   繁体   English

Bootstrap 的 JavaScript 需要 jQuery 1.9.1 或更高版本,但低于版本 3

[英]Bootstrap's JavaScript requires jQuery version 1.9.1 or higher, but lower than version 3

Introduction简介

I am working with the bootstrap framework.I am currently working on "Bootstrap Tabs"(hide/show).I am using bootstrap version 3 and jquery version 3.0.2 something.我正在使用引导程序框架。我目前正在研究“引导程序选项卡”(隐藏/显示)。我正在使用引导程序版本 3 和 jquery 版本 3.0.2。

Problem问题

My tabs are not working, unless i load jquery of version less than 1.6.But then ajax making problem with jquery less than 1.6.我的选项卡不起作用,除非我加载版本低于 1.6 的 jquery。但是 ajax 使 jquery 低于 1.6 出现问题。 Chrome console give me this error. Chrome 控制台给我这个错误。

bootstrap.min.js:6 Uncaught Error: Bootstrap's JavaScript requires jQuery version 1.9.1 or higher, but lower than version 3 bootstrap.min.js:6 未捕获错误:Bootstrap 的 JavaScript 需要 jQuery 1.9.1 或更高版本,但低于版本 3

I tried different fallback techniques but couldn't implement correctly.我尝试了不同的回退技术,但无法正确实施。

I am stuck here for 2 days, if someone have any idea or any reference, please do help.Thanks for your time.我在这里被困了 2 天,如果有人有任何想法或任何参考,请帮忙。感谢您的时间。

Currently Bootstrap 3.x does not support jQuery 3.x as reported here: https://github.com/twbs/bootstrap/issues/16834目前 Bootstrap 3.x 不支持 jQuery 3.x,如此处报道: https : //github.com/twbs/bootstrap/issues/16834

The issue is caused by:问题是由以下原因引起的:

jQuery 3 is more strict than jQuery 2. It's like XHTML and HTML. jQuery 3 比 jQuery 2 更严格。它就像 XHTML 和 HTML。 Backward compatibility is preserved and code doesn't look like a mess.向后兼容性得以保留,代码看起来不会一团糟。 If I'm not mistaken, all you need to do is replace show() and hide() functions with .css('display', '') or addClass('hidden') and fix a selector in alert.js (QUnit fails on this line because $('#') is invalid in jQuery 3)如果我没记错的话,您需要做的就是将 show() 和 hide() 函数替换为 .css('display', '') 或 addClass('hidden') 并修复 alert.js 中的选择器(QUnit在这一行失败,因为 $('#') 在 jQuery 3 中无效)

It is fixed in the Bootstrap 3.3.7 release: https://github.com/twbs/bootstrap/issues/16834#issuecomment-225039913它在 Bootstrap 3.3.7 版本中得到修复: https : //github.com/twbs/bootstrap/issues/16834#issuecomment-225039913

最新版本的 Bootstrap (3.3.7) 现在支持 jQuery 3+,根据这里的开发人员评论https://github.com/twbs/bootstrap/issues/16834

If you use Bower to manage your javascript packages, to exclude jquery 3.0 you should specify the version of jquery like:如果您使用 Bower 管理您的 javascript 包,要排除 jquery 3.0,您应该指定 jquery 的版本,例如:

"jquery": "^2.2"

in your bower.json .在你的bower.json

The bower.json of jquery-ui package has a following line: jquery-ui包的bower.json有如下一行:

"jquery": ">=1.6"

Because of it Bower installs the latest version of jQuery, which causes your problem.因此,Bower 安装了最新版本的 jQuery,这会导致您的问题。

Note that jQuery 3.0 is released as of June 9, 2016.请注意,jQuery 3.0 于 2016 年 6 月 9 日发布。

What solved my problem is actually loading jquery lower version before bootstrap.js and then loading jquery higher version after bootstrap.js to resolve conflicts.Above is my example解决我的问题实际上是在 bootstrap.js 之前加载 jquery 较低版本,然后在 bootstrap.js 之后加载 jquery 较高版本以解决冲突。 以上是我的例子

<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js"></script>
<script src="~/App_Theme/bootstrap/js/bootstrap.min.js"></script>
<script>
    var $j = jQuery.noConflict();
</script>

<script src="http://ajax.googleapis.com/ajax/libs/jquery/3.0.0/jquery.min.js"></script>
<script>
    var $ = jQuery.noConflict();
</script>

As for me, everything simple.至于我,一切都很简单。 It's all about queue links files.这都是关于队列链接文件的。 I need to move links like this:我需要移动这样的链接:

<head>
     <script src="js/jquery1.9.1.js"></script>
     <script src="js/bootstrap.js"> </script>       
</head>

After all - it's working prorerly.毕竟 - 它工作正常。

I had same problem and I have not jquery 1.8.2 in my web pages.I solve my problem by change version of jquery in packages.config我有同样的问题,我的网页中没有 jquery 1.8.2。我通过在packages.config 中更改 jquery 版本来解决我的问题

change改变

  <package id="AspNet.ScriptManager.jQuery" version="1.8.2" targetFramework="net45" />
 <package id="jQuery" version="1.8.2" targetFramework="net45" />

to

<package id="AspNet.ScriptManager.jQuery" version="2.1.4" targetFramework="net45" />
 <package id="jQuery" version="2.1.4" targetFramework="net45" />

my jquery version is 2.1.4我的 jquery 版本是2.1.4

所以我有了新版本的 Bootstrap,但由于某种原因,min 版本仍然是不支持 JQuery 3 的旧版本。我删除了缩小的 bootstrap JS,然后重新缩小了新的 Bootstrap.js 并部署,问题就消失了。

Put This Code In Functions.php将此代码放在 Functions.php 中

wp_deregister_script(‘jquery’);
wp_register_script(‘jquery’, ‘//cdnjs.cloudflare.com/ajax/libs/jquery/2.2.4/jquery.min.js’, false, null);
wp_enqueue_script(‘jquery’);

Here is Reference URL: https://wordpress.org/support/topic/error-bootstraps-javascript-requires-at-least-jquery-v1-9-1/这是参考网址: https : //wordpress.org/support/topic/error-bootstraps-javascript-requires-at-least-jquery-v1-9-1/


With a migration to wordpress 5.6, i had the same problem : a conflict between bootstrap and jquery.随着迁移到 wordpress 5.6,我遇到了同样的问题:bootstrap 和 jquery 之间的冲突。 Navigation on my websites didn't work for all dropdown menus.我网站上的导航不适用于所有下拉菜单。 I have changed boostrap3.3.6 to boostrap3.3.7 in my folder css + js to get a bootstrap working with jquery 1.9.1 and it works.我已经在我的文件夹 css + js 中将 boostrap3.3.6 更改为 boostrap3.3.7 以获得使用 jquery 1.9.1 的引导程序并且它可以工作。

I also ran across this error in WordPress 5.6 where accordions stopped working.我也在 WordPress 5.6 中遇到了这个错误,手风琴停止工作。 Upgrading the JS and CSS from boostrap3.3.6 to boostrap3.3.7 fixed the error for me too.将 JS 和 CSS 从 boostrap3.3.6 升级到 boostrap3.3.7 也修复了我的错误。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 bootstrap.js:未捕获的错误:Bootstrap的JavaScript需要jQuery 1.9.1或更高版本,但低于版本3 - bootstrap.js: Uncaught Error: Bootstrap's JavaScript requires jQuery version 1.9.1 or higher, but lower than version 3 Bootstrap 的 JavaScript 需要 jQuery 1.9.1 或更高版本 - Bootstrap's JavaScript requires jQuery version 1.9.1 or higher 未捕获的错误:Bootstrap的JavaScript需要jQuery 1.12.4或更高版本,但日期时间选择器低于jQuery 3。 - Uncaught Error: Bootstrap's JavaScript requires jQuery version 1.12.4 or higher, but lower than version 3 in date time picker com.gargoylesoftware.htmlunit.ScriptException:错误:Bootstrap 的 JavaScript 需要 jQuery 1.9.1 或更高版本 - com.gargoylesoftware.htmlunit.ScriptException: Error: Bootstrap's JavaScript requires jQuery version 1.9.1 or higher JQuery代码适用于1.5.2版,但不适用于1.9.1版 - JQuery code, works in version 1.5.2 but not in version 1.9.1 react-bootstrap-table-next@4.0.3 需要 underscore@1.9.1 最早的固定版本是 1.12.1 - Dependabot alert - react-bootstrap-table-next@4.0.3 requires underscore@1.9.1 The earliest fixed version is 1.12.1 - Dependabot alert jQuery切换和动画与1.9.1及更高版本不兼容吗? - jQuery toggle and animate not compatible with version 1.9.1 and up? Bootstrap的JavaScript需要在vue 2.5中使用jQuery - Bootstrap's JavaScript requires jQuery in vue 2.5 Bootstrap 的 JavaScript 需要 jQuery - Reactjs - Bootstrap's JavaScript requires jQuery - Reactjs Ember Fastboot-Bootstrap的Javascript需要jQuery吗? - Ember Fastboot - Bootstrap's Javascript requires jQuery?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM