当我使用本地文件时,为什么我会丢失启动下拉菜单

Why do I lose Bootstrap Dropdown Menus when I use local files?

本文关键字:为什么 启动 下拉菜单 文件      更新时间:2023-09-26

我已经使用Bootstrap一年了,它运行得很好。但当我尝试在本地使用这些文件时,结果总是一样的:我的导航栏下拉菜单停止下拉。

有人看到我做错了什么吗?

<!doctype html>
<html class="no-js" lang="en">
<head>
    <meta charset="utf-8">
    <meta http-equiv="x-ua-compatible" content="ie=edge">
    <title></title>
    <meta name="description" content="">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <link rel="apple-touch-icon" href="apple-touch-icon.png">
    <!-- Place favicon.ico in the root directory -->
    <script src="js/jquery.min.js"></script>
    <script src="js/plugins.js"></script>
    <script src="js/jquery-ui-1.11.4/jquery-ui.min.js"></script>
    <!-- Latest compiled and minified CSS -->
    <link rel="stylesheet" href="css/bootstrap.min.css">
    <!-- Optional theme -->
    <link rel="stylesheet" href="css/bootstrap-theme.min.css">
    <!-- Latest compiled and minified JavaScript -->
    <script src="js/bootstrap.min.js"></script>

错误为:

wsschedulepolygraphs.php:14 GET http://localhost/dfwit/js/jquery.min.js 
wsschedulepolygraphs.php:17 GET http://localhost/dfwit/js/jquery-ui-1.11.4/jquery-ui.min.js 
bootstrap.min.js:6 Uncaught Error: Bootstrap's JavaScript requires jQuery(anonymous function) @ bootstrap.min.js:6
dropdown-enhancement.js:267 Uncaught ReferenceError: jQuery is not defined(anonymous function) @ dropdown-enhancement.js:267
wsschedulepolygraphs.php:434 Uncaught ReferenceError: $ is not defined(anonymous function) @ wsschedulepolygraphs.php:434
wsschedulepolygraphs.php:530 Uncaught ReferenceError: $ is not defined

在读取文件时,对目录的不正确权限会导致403和其他访问错误。从命令行检查当前目录的所有者和组:

~$ ls -ld
drwxr-xr-x  2 owner group 4096 Aug 12 19:12 Desktop

来源:如何查找目录的所有者和组

https://superuser.com/a/91966

只要看一下代码,您的引导程序路径就与所有其他JavaScript包含的路径不同。

<script src="js/jquery.min.js"></script>
            ^^^
<script src="/js/bootstrap.min.js"></script>
            ^^^

js文件的路径不正确。同样,对于下面的代码,js之前的/可能会导致问题

<script src="/js/bootstrap.min.js"></script>