在gh页中托管的Angular项目找不到文件并显示空白页

时间:2019-12-13 22:30:50

标签: angular github-pages

我构建了一个运行ng build命令的Angular项目,并且在本地运行良好。

我将dist文件夹的内容上载到Github中的存储库并创建了它的GitHub Page,但是它不呈现任何内容。看着控制台,它抛出错误,表明找不到任何捆绑软件文件。

The browser trying to find these files outside the repository

为什么它不在存储库中但在外部的文件夹中查找文件?

谢谢。

1 个答案:

答案 0 :(得分:1)

您需要更改base href中的index.html

将您的github页面网址添加到base href

<base href="https://jcrr1985.github.io/tutenTestD/">

我已经分叉了您的github,现在可以正常工作了。选中index.html

index.html

<!doctype html>
<html lang="en">

<head>
    <meta charset="utf-8">
    <title>Tuten</title> 
    <base href="https://jcrr1985.github.io/tutenTestD/"> <!-- changes here -->

    <meta name="viewport" content="width=device-width, initial-scale=1">
    <link rel="icon" type="image/x-icon" href="favicon.ico">

    <link href="https://fonts.googleapis.com/icon?family=Material+Icons" rel="stylesheet">
</head>

<body>
    <app-root></app-root>
    <script type="text/javascript" src="runtime.js"></script><script type="text/javascript" src="polyfills.js"></script><script type="text/javascript" src="styles.js"></script><script type="text/javascript" src="vendor.js"></script><script type="text/javascript" src="main.js"></script></body>

</html>
相关问题