我现在有2页。我正在做的是,我正在尝试页面转换,我正在使用下面的插件swup。现在我的问题是当我点击菜单时页面转换不起作用。
我在 href 中
添加了类似/index
和的菜单,我的 URL 是,当我点击菜单时,我得到并且 URL 正在显示/about
http://localhost:8080/example/index
object not found
http://localhost:8080/about
谁能帮我解决这个问题?
头文件.php
<header>
<div>
<ul>
<li><a href="/index">Index</a></li>
<li><a href="/about">About</a></li>
</ul>
</div>
</header>
索引.php
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Home</title>
<link href="assets/css/style.css">
</head>
<body>
<?php include('assets/include/header.php');?>
<div id="swup" class="transition-fade">
<h1>This is homepage</h1>
<p>
Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.
</p>
</div>
<script src="https://unpkg.com/swup@latest/dist/swup.min.js"></script>
<script src="assets/js/main.js"></script>
</body>
</html>
关于.php
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>About Document</title>
<link href="assets/css/style.css">
</head>
<body>
<?php include('assets/include/header.php');?>
<div id="swup" class="transition-fade">
<h1>This is Aboutpage</h1>
<p>
Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.
</p>
</div>
<script src="https://unpkg.com/swup@latest/dist/swup.min.js"></script>
<script src="assets/js/main.js"></script>
</body>
</html>
样式.css
.transition-fade {
transition: 0.4s;
opacity: 1;
}
html.is-animating .transition-fade {
opacity: 0;
}
main.js
import Swup from 'swup';
const swup = new Swup();