Bootstrap.js必须在jQuery之前加载 [英] Bootstrap.js has to load before jQuery

查看:392
本文介绍了Bootstrap.js必须在jQuery之前加载的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试使Bootstrap下拉功能正常工作,但是注意到一些非常奇怪的事情.

I'm try to get the Bootstrap drop down functionality to work, but am noticing something very odd.

出于某种原因,我必须在jquery之前加载bootstrap.min.js才能使下拉列表正常工作.

For some reason, I have to load the bootstrap.min.js BEFORE jquery in order for the drop down to work.

以下是下拉菜单不起作用的代码:

Here is the code when drop-downs don't work:

<script src="//ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js" type="text/javascript"></script>

<script src="js/bootstrap.min.js" type="text/javascript"></script>

然后,如果我将它们切换(jQuery之前的引导程序),则下拉菜单将神奇地起作用.我不明白为什么这是在考虑引导程序需要查询才能运行,否则我在Firebug中收到以下错误:

Then, if I switch them around (bootstrap before jquery), drop-down magically works. I don't understand why this is considering bootstrap needs query to run, otherwise I get an error in Firebug of:

ReferenceError: Can't find variable: jQuery

任何解释和/或帮助都将很棒!

Any explanation and/or help would be great!

推荐答案

我想这是因为您在

 $(document).ready(function() { })

如果您首先加载引导程序,则它可能在实际调用引导程序代码之前完成,但在jquery完成加载之前完成,因此缺少引用.到现在为止都很难看到代码,您是否只是使用data-api作为下拉菜单?

If you load bootstrap first, it may finish before the call is actually made to the bootstrap code, but before jquery finishes loading, hence the missing reference. tho its hard to now without seeing the code, are you just using the data-api for the dropdown?

这篇关于Bootstrap.js必须在jQuery之前加载的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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