在我的网站上,我有一个index.php
带导航栏的。然后,我需要添加另一个名为 的页面second.php
,并相应地更新我的导航栏代码(我有一个nav.html
导航栏文件,以便我可以使用 JS 将它加载到站点的每个页面上)。我还将导航栏代码添加到second.php
. 但是,当我打开时,没有出现index.php
指向的链接。second.php
我尝试重新启动我的计算机,重新启动我的 MAMP 服务器,重新打开我的代码编辑器,重新打开浏览器,但没有任何效果。然后,我尝试重命名我的文件(出于测试目的以及因为我需要更好的文件名)并相应地更新文件名的所有实例。但后来出现了:
然后是我的目录中的文件列表。特别是,该网站没有显示。有人可以解释发生了什么以及我该如何解决吗?
nav.html:
<body>
<header>
<div class="logo">
<h1 class="logo-text"><a href="home.php">Welcome!</a></h1>
</div>
<i class="fa fa-bars menu-toggle"></i>
<ul class="nav">
<li><a href="home.php">Home</a></li>
<li><a href="about.php">About</a></li>
</ul>
</header>
</body>
home.php(以前second.php):
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie-edge">
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/5.13.0/css/all.min.css">
<link rel="stylesheet" href="css/style.css?v=<?php echo time(); ?>">
<!-- Font Awesome -->
<link rel="stylesheet" href="//use.fontawesome.com/releases/v5.0.7/css/all.css">
<!-- Fonts -->
<link href="https://fonts.googleapis.com/css2?family=Kalam&family=Pangolin&display=swap" rel="stylesheet">
<link href="https://fonts.googleapis.com/css2?family=Roboto&display=swap" rel="stylesheet">
<!-- JQuery -->
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.5.1/jquery.min.js" integrity="sha256-9/aliU8dGd2tb6OSsuzixeV4y/faTqgFtohetphbbj0=" crossorigin="anonymous"></script>
<title>Welcome Home</title>
</head>
<body>
<div class="placeholder"></div>
<script>
$(function(){
$('.placeholder').load("nav.html");
});
</script>
hello world
<script src="js/main.js"></script>
</body>
</html>
about.php(以前的)与除了它有几个段落标签外index.html基本相同。home.php
慕村225694