0

我现在有2页。我正在做的是,我正在尝试页面转换,我正在使用下面的插件swup。现在我的问题是当我点击菜单时页面转换不起作用。

我在 href 中 添加了类似/index和的菜单,我的 URL 是,当我点击菜单时,我得到并且 URL 正在显示/abouthttp://localhost:8080/example/indexobject not foundhttp://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();
4

1 回答 1

0

您的链接是错误的,基本上会导致页面不存在。

将您的菜单链接更改为:

<li><a href="/example/index">Index</a></li>
<li><a href="/example/about">About</a></li>
于 2020-06-07T22:08:21.643 回答