简体   繁体   English

无法获取 /index.html VS 代码

[英]Cannot Get /index.html VS Code

I was doing a page trasition exercise and in the vídeo the person created two more html files and ended up with three: index.html, about.html and pricing.html. I was doing a page trasition exercise and in the vídeo the person created two more html files and ended up with three: index.html, about.html and pricing.html. but the html files that were work before now just keep giving me the error "Cannot Get /index.html", "Cannot Get /about.html", "Cannot Get /pricing.html" and the problem seems to be with the / that are put before the html names, whoever, if i remove the / then the trasition showned in the vídeo doesn't occurs.但是之前工作的 html 文件一直给我错误“无法获取 /index.html”、“无法获取 /about.html”、“无法获取 /pricing.html”,问题似乎与 /放在 html 名称之前,无论是谁,如果我删除 / 则不会发生视频中显示的转换。

And also, just to finish it, my script.js has those three dots under the Swup() part and i don't kwon if this disturb my code.而且,为了完成它,我的 script.js 在 Swup() 部分下有这三个点,如果这会干扰我的代码,我不知道。

<!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 rel="stylesheet" href="style.css">
    <script defer src="node_modules/swup/dist/swup.min.js"></script>
    <script defer src="script.js"></script>
    </head>  
    <body>
        <nav>
            <ul>
                <li><a href="/index.html">Home</a></li>
                <li><a href="/pricing.html">Pricing</a></li>
                <li><a href="/about.html">About</a></li>
            </ul>
        </nav>
        <main id="swup" class="transition-fade">
            <h1>This is the home page</h1>
        </main>
    </body>
    </html>

(The code is the same for all of the html files. only thing that changes is the "home" in h1 that become "about" and "pricing") (所有 html 文件的代码都是相同的。唯一改变的是 h1 中的“家”变成了“关于”和“定价”)

const swup = new Swup()

The issue is the fact that the "/" links it to the root;问题在于“/”将其链接到根目录; if you just run the file directly in a browser, it wouldn't work, as the "root" is the drive.如果您只是直接在浏览器中运行该文件,它将无法工作,因为“根”是驱动器。 I personally use the Live Server extension, as it makes the project directory the root (using localhost:3500 ), mimicking an actual website.我个人使用Live Server扩展,因为它使项目目录成为根目录(使用localhost:3500 ),模仿实际网站。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM