措手不及:Bootstrap的JavaScript需要jQuery [英] Uncaught: Bootstrap's JavaScript requires jQuery

查看:96
本文介绍了措手不及:Bootstrap的JavaScript需要jQuery的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在页脚部分包含了jquery和bootstrap.min.js文件,或者这意味着我的所有脚本标签都位于代码底部.但是,当我加载页面时,浏览器控制台抛出错误:未捕获的错误:Bootstrap的JavaScript需要jQuery. 我在本地包含这些文件,如下所示:-

I have included jquery and bootstrap.min.js file in my footer section or it means i have my all script tag at the bottom of the code. But when i am loading my page the browser console throw an error says : Uncaught Error: Bootstrap's JavaScript requires jQuery. I am including these files locally like below:-

</footer>
<script src="http://127.0.0.1/ems_ci/assets/js/jquery.js" type="text/javascript"></script>
<script src="http://127.0.0.1/ems_ci/assets/js/bootstrap.min.js" type="text/javascript"></script>
</body>
</html>

推荐答案

使用localhost127.0.0.1作为文件路径并不常见.改为使用relative path.

It's uncommon to use localhost or 127.0.0.1 for a file path. Use relative path instead.

关于脚本位置:您可以将它们保留在页脚中,这将加快页面加载速度,但请确保在dom中jquery/bootstrap之后执行的任何JavaScript代码. 并且不要忘记将代码包装在document ready jquery函数

Regarding script position: you can leave them in the footer, that will speed up page loading, but make sure any JavaScript code you execute is AFTER jquery/bootstrap in the dom. And don't forget to wrap your code inside a document ready jquery function

这篇关于措手不及:Bootstrap的JavaScript需要jQuery的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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